From d1909a5ad863b3769d7131e8d2f41e27cbf0d894 Mon Sep 17 00:00:00 2001 From: Matthew Dev Date: Tue, 29 Jul 2014 14:07:55 -0400 Subject: [PATCH 001/436] Fix missing "use" in `PatternLab\Annotations` - `PatternLab\Parsers\Documentation` needs a `use` --- src/PatternLab/Annotations.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index f6d0e645..c69131fd 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -15,6 +15,7 @@ use \PatternLab\Config; use \PatternLab\Console; use \PatternLab\Dispatcher; +use \PatternLab\Parsers\Documentation; use \Symfony\Component\Yaml\Exception\ParseException; use \Symfony\Component\Yaml\Yaml; use \PatternLab\Timer; From 0bfa1114fcba64c4755545d593c9fd7f1ebca078 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 31 Jul 2014 14:19:45 -0400 Subject: [PATCH 002/436] no need to check prompt here --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index c38924f6..2468ceb8 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -281,7 +281,7 @@ public static function updateConfigOption($optionName,$optionValue) { $input = strtolower(trim(fgets($stdin))); fclose($stdin); - if (!$prompt && ($input == "y")) { + if ($input == "y") { self::writeUpdateConfigOption($optionName,$optionValue); Console::writeLine("config option ".$optionName." updated...", false, true); } else { From 95e93c837e20f79e38078ff53e200a1e42f16833 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 31 Jul 2014 14:19:51 -0400 Subject: [PATCH 003/436] fixing a type --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index b52c0b37..3780ca6b 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -214,7 +214,7 @@ protected static function runTasks($event,$type) { $extra = $package->getExtra(); $type = $package->getType(); $name = $package->getName(); - $pathBase = Config::getOption("packagesDir")."/".$name. + $pathBase = Config::getOption("packagesDir")."/".$name; $pathDist = $pathBase."/dist/"; // make sure we're only evaluating pattern lab packages From af3aa8ff311a324978f402b813dcf1de2a8749c3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Aug 2014 14:50:04 -0400 Subject: [PATCH 004/436] removing dev-master alias --- composer.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/composer.json b/composer.json index 96be20c3..b8d572e0 100644 --- a/composer.json +++ b/composer.json @@ -38,10 +38,5 @@ "symfony/filesystem": "v2.5.0", "kevinlebrun/colors.php": "0.*", "pattern-lab/unified-asset-installer": "dev-master" - }, - "extra": { - "branch-alias": { - "dev-master": "dev-dev" - } } } From ef980a98cfb3e2a1ec1890ec931b07baf9a329a8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Aug 2014 16:27:34 -0400 Subject: [PATCH 005/436] sharing the init functions --- src/PatternLab/InstallerUtil.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 3780ca6b..b53094f7 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -20,6 +20,20 @@ class InstallerUtil { + /** + * Common init sequence + */ + protected static function init() { + + // initialize the console to print out any issues + Console::init(); + + // initialize the config for the pluginDir + $baseDir = __DIR__."/../../../../../"; + Config::init($baseDir,false); + + } + /** * Move the files from the package to their location in the public dir or source dir * @param {String} the name of the package @@ -157,12 +171,8 @@ public static function postPackageUpdate($event) { */ public static function preInstallCmd($event) { - // initialize the console to print out any issues - Console::init(); - - // initialize the config - $baseDir = __DIR__."/../../../../../"; - Config::init($baseDir,false); + // run the console and config inits + self::init(); // default vars $sourceDir = Config::getOption("sourceDir"); @@ -202,12 +212,8 @@ protected static function removeDots($path) { */ protected static function runTasks($event,$type) { - // initialize the console to print out any issues - Console::init(); - - // initialize the config for the pluginDir - $baseDir = __DIR__."/../../../../../"; - Config::init($baseDir,false); + // run the console and config inits + self::init(); // get package info $package = ($type == "install") ? $event->getOperation()->getPackage() : $event->getOperation()->getTargetPackage(); From da212db692f714703d6b47d7b87679854c9f75be Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Aug 2014 16:28:13 -0400 Subject: [PATCH 006/436] pre package install command --- src/PatternLab/InstallerUtil.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index b53094f7..f8a5d8e4 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -189,6 +189,31 @@ public static function preInstallCmd($event) { } + /** + * Make sure pattern engines and listeners are removed on uninstall + * @param {Object} a script event object from composer + */ + public static function prePackageUninstallCmd($event) { + + // run the console and config inits + self::init(); + + // get package info + $package = $event->getOperation()->getPackage(); + $type = $package->getType(); + $name = $package->getName(); + $pathBase = Config::getOption("packagesDir")."/".$name; + + // see if the package has a listener and remove it + self::scanForListener($pathBase,true); + + // see if the package is a pattern engine and remove the rule + if ($type == "patternlab-patternengine") { + self::scanForPatternEngineRule($pathBase,true); + } + + } + /** * Remove dots from the path to make sure there is no file system traversal when looking for or writing files * @param {String} the path to check and remove dots From 231b524da2b5612454fb93e9224595b8000994b7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Aug 2014 16:28:42 -0400 Subject: [PATCH 007/436] support for removing listeners and pattern engines on uninstall --- src/PatternLab/InstallerUtil.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index f8a5d8e4..d8bc7e5c 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -316,7 +316,7 @@ protected static function runTasks($event,$type) { * Scan the package for a listener * @param {String} the path for the package */ - protected static function scanForListener($pathPackage) { + protected static function scanForListener($pathPackage,$remove = false) { // get listener list path $pathList = Config::getOption("packagesDir")."/listeners.json"; @@ -344,9 +344,12 @@ protected static function scanForListener($pathPackage) { $dirs = explode("/",$object->getPath()); $listenerName = "\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$object->getFilename()); - // make sure it's not already in the list - if (!in_array($listenerName,$listenerList)) { + // check to see what we should do with the listener info + if (!$remove && !in_array($listenerName,$listenerList["listeners"])) { $listenerList["listeners"][] = $listenerName; + } else if ($remove && in_array($listenerName,$listenerList["listeners"])) { + $key = array_search($listenerName, $listenerList["listeners"]); + unset($listenerList["listeners"][$key]); } // write out the listener list @@ -362,7 +365,7 @@ protected static function scanForListener($pathPackage) { * Scan the package for a pattern engine rule * @param {String} the path for the package */ - protected static function scanForPatternEngineRule($pathPackage) { + protected static function scanForPatternEngineRule($pathPackage,$remove = false) { // get listener list path $pathList = Config::getOption("packagesDir")."/patternengines.json"; @@ -390,9 +393,12 @@ protected static function scanForPatternEngineRule($pathPackage) { $dirs = explode("/",$object->getPath()); $patternEngineName = "\\".$dirs[count($dirs)-3]."\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$object->getFilename()); - // make sure it's not already in the list - if (!in_array($patternEngineName ,$patternEngineList)) { + // check what we should do with the pattern engine info + if (!$remove && !in_array($patternEngineName, $patternEngineList["patternengines"])) { $patternEngineList["patternengines"][] = $patternEngineName; + } else if ($remove && in_array($patternEngineName, $patternEngineList["patternengines"])) { + $key = array_search($patternEngineName, $patternEngineList["patternengines"]); + unset($patternEngineList["patternengines"][$key]); } // write out the pattern engine list From 28f8b37b2ecb45255449799105637133e6c11f44 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Aug 2014 16:28:56 -0400 Subject: [PATCH 008/436] fixing a bad array attribute --- src/PatternLab/InstallerUtil.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index d8bc7e5c..81a2e951 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -259,27 +259,27 @@ protected static function runTasks($event,$type) { // move assets to the base directory if (isset($extra["dist"]["baseDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("baseDir"),$extra["assets"]["baseDir"]); + self::parseFileList($name,$pathDist,Config::getOption("baseDir"),$extra["dist"]["baseDir"]); } // move assets to the public directory if (isset($extra["dist"]["publicDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("publicDir"),$extra["assets"]["publicDir"]); + self::parseFileList($name,$pathDist,Config::getOption("publicDir"),$extra["dist"]["publicDir"]); } // move assets to the source directory if (isset($extra["dist"]["sourceDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("sourceDir"),$extra["assets"]["sourceDir"]); + self::parseFileList($name,$pathDist,Config::getOption("sourceDir"),$extra["dist"]["sourceDir"]); } // move assets to the scripts directory if (isset($extra["dist"]["scriptsDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("scriptsDir"),$extra["assets"]["scriptsDir"]); + self::parseFileList($name,$pathDist,Config::getOption("scriptsDir"),$extra["dist"]["scriptsDir"]); } // move assets to the data directory if (isset($extra["dist"]["dataDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$extra["assets"]["scriptsDir"]); + self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$extra["dist"]["scriptsDir"]); } // see if we need to modify the config From 0e15d1cccdb4973053d1552541989e5cedf625e7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 2 Aug 2014 14:04:09 -0400 Subject: [PATCH 009/436] removing unnecessary ish configs --- config/config.ini.default | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/config.ini.default b/config/config.ini.default index 2e1de6a8..49626723 100644 --- a/config/config.ini.default +++ b/config/config.ini.default @@ -31,8 +31,3 @@ exportDir = "export" packagesDir = "packages" publicDir = "public" sourceDir = "source" - -// ish options -ishFontSize = "16px" -ishMaximum = "2400" -ishMinimum = "240" From e38180d78cb5ff4e0fc88fa44d970488cbe07850 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 2 Aug 2014 16:17:44 -0400 Subject: [PATCH 010/436] use dev-dev of unified-asset-installer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b8d572e0..414bb472 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,6 @@ "symfony/event-dispatcher": "v2.5.0", "symfony/filesystem": "v2.5.0", "kevinlebrun/colors.php": "0.*", - "pattern-lab/unified-asset-installer": "dev-master" + "pattern-lab/unified-asset-installer": "dev-dev" } } From 36e3de22c1f285a1989a65947c3c43485421fed1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 2 Aug 2014 22:21:35 -0400 Subject: [PATCH 011/436] added more events --- src/PatternLab/Annotations.php | 8 ++++ src/PatternLab/Builder.php | 46 ++++++++++++++++++ src/PatternLab/Data.php | 16 ++++++- src/PatternLab/FileUtil.php | 9 ++++ src/PatternLab/Generator.php | 86 ++++++++++++++++++++-------------- 5 files changed, 129 insertions(+), 36 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index c69131fd..46b11fb6 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -31,6 +31,12 @@ class Annotations { */ public static function gather() { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // dispatch that the data gather has started + $dispatcherInstance->dispatch("annotations.gatherStart"); + // set-up the comments store self::$store["comments"] = array(); @@ -91,6 +97,8 @@ public static function gather() { // merge in any data from the old file self::$store["comments"] = array_merge(self::$store["comments"],$data["comments"]); + $dispatcherInstance->dispatch("annotations.gatherEnd"); + } /** diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 22a8814d..416bb30c 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -15,6 +15,7 @@ use \PatternLab\Annotations; use \PatternLab\Config; use \PatternLab\Data; +use \PatternLab\Dispatcher; use \PatternLab\Parsers\Documentation; use \PatternLab\PatternData\Exporters\NavItemsExporter; use \PatternLab\PatternData\Exporters\PatternPartialsExporter; @@ -85,6 +86,12 @@ protected function gatherMQs() { */ protected function generateAnnotations() { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // note the start of the operation + $dispatcherInstance->dispatch("builder.generateAnnotationsStart"); + // default var $publicDir = Config::getOption("publicDir"); @@ -99,6 +106,9 @@ protected function generateAnnotations() { // write out the new annotations.js file file_put_contents($publicDir."/annotations/annotations.js","var comments = ".$json.";"); + // note the end of the operation + $dispatcherInstance->dispatch("builder.generateAnnotationsEnd"); + } /** @@ -106,6 +116,12 @@ protected function generateAnnotations() { */ protected function generateIndex() { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // note the start of the operation + $dispatcherInstance->dispatch("builder.generateIndexStart"); + // default var $dataDir = Config::getOption("publicDir")."/styleguide/data"; @@ -150,6 +166,9 @@ protected function generateIndex() { // write out the data file_put_contents($dataDir."/patternlab-data.js",$output); + // note the end of the operation + $dispatcherInstance->dispatch("builder.generateIndexEnd"); + } /** @@ -158,6 +177,12 @@ protected function generateIndex() { */ protected function generatePatterns($options = array()) { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // note the beginning of the operation + $dispatcherInstance->dispatch("builder.generatePatternsStart"); + // set-up common vars $exportFiles = (isset($options["exportFiles"]) && $options["exportFiles"]); $exportDir = Config::getOption("exportDir"); @@ -213,6 +238,9 @@ protected function generatePatterns($options = array()) { } + // note the end of the operation + $dispatcherInstance->dispatch("builder.generatePatternsEnd"); + } /** @@ -220,6 +248,12 @@ protected function generatePatterns($options = array()) { */ protected function generateStyleguide() { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // note the beginning of the operation + $dispatcherInstance->dispatch("builder.generateStyleguideStart"); + // default var $publicDir = Config::getOption("publicDir"); @@ -251,6 +285,9 @@ protected function generateStyleguide() { file_put_contents($publicDir."/styleguide/html/styleguide.html",$styleGuidePage); + // note the end of the operation + $dispatcherInstance->dispatch("builder.generateStyleguideEnd"); + } /** @@ -258,6 +295,12 @@ protected function generateStyleguide() { */ protected function generateViewAllPages() { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // note the beginning of the operation + $dispatcherInstance->dispatch("builder.generateViewAllPagesStart"); + // default vars $patternPublicDir = Config::getOption("patternPublicDir"); $htmlHead = Template::getHTMLHead(); @@ -345,6 +388,9 @@ protected function generateViewAllPages() { } + // note the end of the operation + $dispatcherInstance->dispatch("builder.generateViewAllPagesEnd"); + } /** diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 4ea74678..424d4ffe 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -37,6 +37,12 @@ class Data { */ public static function gather($options = array()) { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // dispatch that the data gather has started + $dispatcherInstance->dispatch("data.gatherStart"); + // default vars $found = false; $dataJSON = array(); @@ -126,7 +132,7 @@ public static function gather($options = array()) { self::$store["link"] = array(); self::$store["patternSpecific"] = array(); - Dispatcher::getInstance()->dispatch("data.dataLoadEnd"); + $dispatcherInstance->dispatch("data.gatherEnd"); } @@ -148,6 +154,12 @@ public static function get() { */ protected static function getListItems($filepath,$ext = "json") { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // dispatch that the data gather has started + $dispatcherInstance->dispatch("data.getListItemsStart"); + // default vars $sourceDir = Config::getOption("sourceDir"); $listItems = array(); @@ -204,6 +216,8 @@ protected static function getListItems($filepath,$ext = "json") { } + $dispatcherInstance->dispatch("data.getListItemsEnd"); + return $listItems; } diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index 4b123f37..ad7748a7 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -14,6 +14,7 @@ use \PatternLab\Config; use \PatternLab\Console; +use \PatternLab\Dispatcher; use \PatternLab\Timer; use \Symfony\Component\Filesystem\Filesystem; use \Symfony\Component\Filesystem\Exception\IOExceptionInterface; @@ -141,6 +142,12 @@ public static function cleanExport() { */ public static function cleanPublic() { + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // dispatch that the data gather has started + $dispatcherInstance->dispatch("fileUtil.cleanPublicStart"); + // default var $patternPublicDir = Config::getOption("patternPublicDir"); @@ -215,6 +222,8 @@ public static function cleanPublic() { } + $dispatcherInstance->dispatch("fileUtil.cleanPublicEnd"); + } /** diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index 3978423a..c4ffbcc6 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -90,51 +90,67 @@ public function generate($options = array()) { // move all of the files unless pattern only is set if ($moveStatic) { + $this->moveStatic(); + } + + // update the change time so the auto-reload will fire (doesn't work for the index and style guide) + Util::updateChangeTime(); + + Console::writeLine("your site has been generated..."); + + Timer::stop(); + + } + + /** + * Move static files from source/ to public/ + */ + protected function moveStatic() { + + // set-up the dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + + // note the start of the operation + $dispatcherInstance->dispatch("generator.moveStaticStart"); + + // common values + $publicDir = Config::getOption("publicDir"); + $sourceDir = Config::getOption("sourceDir"); + $ignoreExt = Config::getOption("ie"); + $ignoreDir = Config::getOption("id"); + + // iterate over all of the other files in the source directory + $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir), \RecursiveIteratorIterator::SELF_FIRST); + + // make sure dots are skipped + $objects->setFlags(\FilesystemIterator::SKIP_DOTS); + + foreach($objects as $name => $object) { - // common values - $publicDir = Config::getOption("publicDir"); - $sourceDir = Config::getOption("sourceDir"); - $ignoreExt = Config::getOption("ie"); - $ignoreDir = Config::getOption("id"); - - // iterate over all of the other files in the source directory - $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir), \RecursiveIteratorIterator::SELF_FIRST); - - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); + // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored + $fileName = str_replace($sourceDir.DIRECTORY_SEPARATOR,"",$name); - foreach($objects as $name => $object) { + if (($fileName[0] != "_") && (!in_array($object->getExtension(),$ignoreExt)) && (!in_array($object->getFilename(),$ignoreDir))) { + + // catch directories that have the ignored dir in their path + $ignored = FileUtil::ignoreDir($fileName); - // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored - $fileName = str_replace($sourceDir.DIRECTORY_SEPARATOR,"",$name); + // check to see if it's a new directory + if (!$ignored && $object->isDir() && !is_dir($publicDir."/".$fileName)) { + mkdir($publicDir."/".$fileName); + } - if (($fileName[0] != "_") && (!in_array($object->getExtension(),$ignoreExt)) && (!in_array($object->getFilename(),$ignoreDir))) { - - // catch directories that have the ignored dir in their path - $ignored = FileUtil::ignoreDir($fileName); - - // check to see if it's a new directory - if (!$ignored && $object->isDir() && !is_dir($publicDir."/".$fileName)) { - mkdir($publicDir."/".$fileName); - } - - // check to see if it's a new file or a file that has changed - if (!$ignored && $object->isFile() && (!file_exists($publicDir."/".$fileName))) { - FileUtil::moveStaticFile($fileName); - } - + // check to see if it's a new file or a file that has changed + if (!$ignored && $object->isFile() && (!file_exists($publicDir."/".$fileName))) { + FileUtil::moveStaticFile($fileName); } } } - // update the change time so the auto-reload will fire (doesn't work for the index and style guide) - Util::updateChangeTime(); - - Console::writeLine("your site has been generated..."); - - Timer::stop(); + // note the end of the operation + $dispatcherInstance->dispatch("generator.moveStaticEnd"); } From 510891bafb7043de8dbd4d7ceabec2eb2d8b40e0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:55:59 -0400 Subject: [PATCH 012/436] making getSpacer() public --- src/PatternLab/Console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index a328f492..5e1c235e 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -427,7 +427,7 @@ public static function writeLine($line,$doubleSpace = false,$doubleBreak = false * @param {Integer} the longest length of the command's options * @param {Integer} the character length of the given option */ - protected static function getSpacer($lengthLong,$itemLongLength) { + public static function getSpacer($lengthLong,$itemLongLength) { $i = 0; $spacer = " "; $spacerLength = $lengthLong - $itemLongLength; From e848613fc2f16c1c6b0adf78399bba154e1340b3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:56:11 -0400 Subject: [PATCH 013/436] updating docs for writeLine --- src/PatternLab/Console.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 5e1c235e..148da258 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -408,8 +408,10 @@ public static function writeHelpCommand($command = "") { } /** - * Write out a line of the help - * @param {Boolean} handle double-break + * Write out a line to the console + * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line */ public static function writeLine($line,$doubleSpace = false,$doubleBreak = false) { $break = ($doubleBreak) ? PHP_EOL.PHP_EOL : PHP_EOL; From 35fcef67799cb79fe7f457681d60585c1416345d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:56:31 -0400 Subject: [PATCH 014/436] adding new tag specific write functions --- src/PatternLab/Console.php | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 148da258..cb047eb9 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -424,6 +424,61 @@ public static function writeLine($line,$doubleSpace = false,$doubleBreak = false print $space.$c($line)->colorize().$break; } + /** + * Write out a line to the console with info tags + * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line + */ + public static function writeInfo($line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,"info"); + self::writeLine($lineFinal,$doubleSpace,$doubleBreak); + } + + /** + * Write out a line to the console with warning tags + * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line + */ + public static function writeWarning($line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,"warning"); + self::writeLine($lineFinal,$doubleSpace,$doubleBreak); + } + + /** + * Write out a line to the console with error tags + * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line + */ + public static function writeError($line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,"error"); + self::writeLine($lineFinal,$doubleSpace,$doubleBreak); + } + + /** + * Write out a line to the console with error tags + * @param {String} the tag to add to the line + * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line + */ + public static function writeTag($tag,$line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,$tag); + self::writeLine($lineFinal,$doubleSpace,$doubleBreak); + } + + + /** + * Modify a line to include the given tag by default + * @param {String} the content to be written out + */ + public static function addTags($line,$tag) { + $lineFinal = "<".$tag.">".preg_replace("/<[A-z0-9-_]{1,}>[^<]{1,}<\/[A-z0-9-_]{1,}>/","$0<".$tag.">",$line).""; + return $lineFinal; + } + /** * Make sure the space is properly set between long command options and short command options * @param {Integer} the longest length of the command's options From 42f64d57d4829cab18597d8f221ea8a12e27ab9d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:56:55 -0400 Subject: [PATCH 015/436] generic get() to return the overall options --- src/PatternLab/Config.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 2468ceb8..6036c0af 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -44,6 +44,15 @@ protected static function cleanDir($dir) { } + /** + * Get the options set in the config + * + * @return {Array} the options from the config + */ + public static function get() { + return self::$options; + } + /** * Get the value associated with an option from the Config * @param {String} the name of the option to be checked From 295f3b96707f9a62780f9e12d95b14cc6835fc05 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:57:08 -0400 Subject: [PATCH 016/436] removing ishControlsHide specific code --- src/PatternLab/Config.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 6036c0af..2e7149e3 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -185,16 +185,6 @@ public static function init($baseDir = "", $verbose = true) { $values = explode(",",$value); array_walk($values,'PatternLab\Util::trim'); self::$options[$key] = $values; - } else if ($key == "ishControlsHide") { - self::$options[$key] = new \stdClass(); - $class = self::$options[$key]; - if ($value != "") { - $values = explode(",",$value); - foreach($values as $value2) { - $value2 = trim($value2); - $class->$value2 = true; - } - } } } From b1f5bce09d32dce96cc39e69f7d08cf433ffbcba Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:57:25 -0400 Subject: [PATCH 017/436] adding to clean array. need to fix this. --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 2e7149e3..2a397474 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -25,7 +25,7 @@ class Config { protected static $userConfigDirDash = "_config"; protected static $userConfigPath = ""; protected static $plConfigPath = "../../config/config.ini.default"; - protected static $cleanValues = array("ie","id","patternStates","styleGuideExcludes"); + protected static $cleanValues = array("ie","id","patternStates","styleGuideExcludes","ishControlsHide"); protected static $dirAdded = false; /** From 24f336ecfe481a07ee65753daafb1aba0e744f50 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:58:09 -0400 Subject: [PATCH 018/436] initial stab at a config command for list, get, & set --- .../Console/Commands/ConfigCommand.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/PatternLab/Console/Commands/ConfigCommand.php diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php new file mode 100644 index 00000000..268730be --- /dev/null +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -0,0 +1,76 @@ +command = "config"; + + Console::setCommand($this->command,"Configure Pattern Lab","The config command allows for the review and update of Pattern Lab config options.","c"); + Console::setCommandOption($this->command,"list","List the current config options.","To list the current configuration:"); + Console::setCommandOption($this->command,"get:","Get the value for a specific config option.","To get a configuration option:"); + Console::setCommandOption($this->command,"set","Set the value for a specific config option.","To set a configuration option:"); + + } + + public function run() { + + if (Console::findCommandOption("list")) { + + $options = Config::get(); + + ksort($options); + + // find length of longest option + $lengthLong = 0; + foreach ($options as $optionName => $optionValue) { + $lengthLong = (strlen($optionName) > $lengthLong) ? strlen($optionName) : $lengthLong; + } + + // iterate over each option + foreach ($options as $optionName => $optionValue) { + $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; + $optionValue = (!$optionValue) ? "false" : $optionValue; + $spacer = Console::getSpacer($lengthLong,strlen($optionName)); + Console::writeInfo($optionName.":".$spacer."".$optionValue.""); + } + + } else if (Console::findCommandOption("get")) { + + $searchOption = Console::findCommandOptionValue("get"); + $optionValue = Config::getOption($searchOption); + if (!$optionValue) { + Console::writeError("the search config option you provided, ".$searchOption.", does not exists in the config..."); + } else { + $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; + $optionValue = (!$optionValue) ? "false" : $optionValue; + Console::writeInfo($searchOption.": ".$optionValue.""); + } + + } else if (Console::findCommandOption("set")) { + + } else { + + } + + } + +} From 6cb6270c0c9fc2a9d7be83a7c5374ec2d59bc1bc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 10:59:56 -0400 Subject: [PATCH 019/436] reordering the functions --- src/PatternLab/Console.php | 85 +++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index cb047eb9..cb03ff08 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -408,53 +408,67 @@ public static function writeHelpCommand($command = "") { } /** - * Write out a line to the console - * @param {String} the content to be written out - * @param {Boolean} if there should be two spaces added to the beginning of the line - * @param {Boolean} if there should be two breaks added to the end of the line + * Make sure the space is properly set between long command options and short command options + * @param {Integer} the longest length of the command's options + * @param {Integer} the character length of the given option */ - public static function writeLine($line,$doubleSpace = false,$doubleBreak = false) { - $break = ($doubleBreak) ? PHP_EOL.PHP_EOL : PHP_EOL; - if (strpos($line,"") !== false) { - $break = ""; - $line = str_replace("","",$line); + public static function getSpacer($lengthLong,$itemLongLength) { + $i = 0; + $spacer = " "; + $spacerLength = $lengthLong - $itemLongLength; + while ($i < $spacerLength) { + $spacer .= " "; + $i++; } - $space = ($doubleSpace) ? " " : ""; - $c = self::$color; - print $space.$c($line)->colorize().$break; + return $spacer; } /** - * Write out a line to the console with info tags + * Modify a line to include the given tag by default + * @param {String} the content to be written out + */ + public static function addTags($line,$tag) { + $lineFinal = "<".$tag.">".preg_replace("/<[A-z0-9-_]{1,}>[^<]{1,}<\/[A-z0-9-_]{1,}>/","$0<".$tag.">",$line).""; + return $lineFinal; + } + + /** + * Write out a line to the console with error tags * @param {String} the content to be written out * @param {Boolean} if there should be two spaces added to the beginning of the line * @param {Boolean} if there should be two breaks added to the end of the line */ - public static function writeInfo($line,$doubleSpace = false,$doubleBreak = false) { - $lineFinal = self::addTags($line,"info"); + public static function writeError($line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,"error"); self::writeLine($lineFinal,$doubleSpace,$doubleBreak); } /** - * Write out a line to the console with warning tags + * Write out a line to the console with info tags * @param {String} the content to be written out * @param {Boolean} if there should be two spaces added to the beginning of the line * @param {Boolean} if there should be two breaks added to the end of the line */ - public static function writeWarning($line,$doubleSpace = false,$doubleBreak = false) { - $lineFinal = self::addTags($line,"warning"); + public static function writeInfo($line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,"info"); self::writeLine($lineFinal,$doubleSpace,$doubleBreak); } /** - * Write out a line to the console with error tags + * Write out a line to the console * @param {String} the content to be written out * @param {Boolean} if there should be two spaces added to the beginning of the line * @param {Boolean} if there should be two breaks added to the end of the line */ - public static function writeError($line,$doubleSpace = false,$doubleBreak = false) { - $lineFinal = self::addTags($line,"error"); - self::writeLine($lineFinal,$doubleSpace,$doubleBreak); + public static function writeLine($line,$doubleSpace = false,$doubleBreak = false) { + $break = ($doubleBreak) ? PHP_EOL.PHP_EOL : PHP_EOL; + if (strpos($line,"") !== false) { + $break = ""; + $line = str_replace("","",$line); + } + $space = ($doubleSpace) ? " " : ""; + $c = self::$color; + print $space.$c($line)->colorize().$break; } /** @@ -469,30 +483,15 @@ public static function writeTag($tag,$line,$doubleSpace = false,$doubleBreak = f self::writeLine($lineFinal,$doubleSpace,$doubleBreak); } - /** - * Modify a line to include the given tag by default + * Write out a line to the console with warning tags * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line */ - public static function addTags($line,$tag) { - $lineFinal = "<".$tag.">".preg_replace("/<[A-z0-9-_]{1,}>[^<]{1,}<\/[A-z0-9-_]{1,}>/","$0<".$tag.">",$line).""; - return $lineFinal; - } - - /** - * Make sure the space is properly set between long command options and short command options - * @param {Integer} the longest length of the command's options - * @param {Integer} the character length of the given option - */ - public static function getSpacer($lengthLong,$itemLongLength) { - $i = 0; - $spacer = " "; - $spacerLength = $lengthLong - $itemLongLength; - while ($i < $spacerLength) { - $spacer .= " "; - $i++; - } - return $spacer; + public static function writeWarning($line,$doubleSpace = false,$doubleBreak = false) { + $lineFinal = self::addTags($line,"warning"); + self::writeLine($lineFinal,$doubleSpace,$doubleBreak); } } From 48e3809ab5ad5b36736147114f2f3bd1c7e0b08b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:01:57 -0400 Subject: [PATCH 020/436] updating docs for writeTag --- src/PatternLab/Console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index cb03ff08..f3dfc370 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -472,7 +472,7 @@ public static function writeLine($line,$doubleSpace = false,$doubleBreak = false } /** - * Write out a line to the console with error tags + * Write out a line to the console with a specific tag * @param {String} the tag to add to the line * @param {String} the content to be written out * @param {Boolean} if there should be two spaces added to the beginning of the line From d6b47fba158a97c017cb3106f5e5c395ee29f211 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:51:09 -0400 Subject: [PATCH 021/436] making sure writeError exits after it is used --- src/PatternLab/Console.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index f3dfc370..34406826 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -433,7 +433,7 @@ public static function addTags($line,$tag) { } /** - * Write out a line to the console with error tags + * Write out a line to the console with error tags. It forces an exit of the script * @param {String} the content to be written out * @param {Boolean} if there should be two spaces added to the beginning of the line * @param {Boolean} if there should be two breaks added to the end of the line @@ -441,6 +441,7 @@ public static function addTags($line,$tag) { public static function writeError($line,$doubleSpace = false,$doubleBreak = false) { $lineFinal = self::addTags($line,"error"); self::writeLine($lineFinal,$doubleSpace,$doubleBreak); + exit; } /** From 73a5d02b26fa70b22b2124a486f3162ae59502ed Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:51:39 -0400 Subject: [PATCH 022/436] updating the help copy --- src/PatternLab/Console/Commands/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 268730be..67eb6222 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -24,7 +24,7 @@ public function __construct() { $this->command = "config"; - Console::setCommand($this->command,"Configure Pattern Lab","The config command allows for the review and update of Pattern Lab config options.","c"); + Console::setCommand($this->command,"Configure Pattern Lab","The --config command allows for the review and update of existing Pattern Lab config options.","c"); Console::setCommandOption($this->command,"list","List the current config options.","To list the current configuration:"); Console::setCommandOption($this->command,"get:","Get the value for a specific config option.","To get a configuration option:"); Console::setCommandOption($this->command,"set","Set the value for a specific config option.","To set a configuration option:"); From 9f3bd82891c48f244f278af827f541f59ae0865a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:51:53 -0400 Subject: [PATCH 023/436] swapping order so they're alphabetical --- src/PatternLab/Console/Commands/ConfigCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 67eb6222..3da4fa2c 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -25,9 +25,9 @@ public function __construct() { $this->command = "config"; Console::setCommand($this->command,"Configure Pattern Lab","The --config command allows for the review and update of existing Pattern Lab config options.","c"); + Console::setCommandOption($this->command,"get:","Get the value for a specific config option.","To get a configuration option:","","configOption"); Console::setCommandOption($this->command,"list","List the current config options.","To list the current configuration:"); - Console::setCommandOption($this->command,"get:","Get the value for a specific config option.","To get a configuration option:"); - Console::setCommandOption($this->command,"set","Set the value for a specific config option.","To set a configuration option:"); + Console::setCommandOption($this->command,"set:","Set the value for a specific config option.","To set a configuration option:","","configOption=\"configValue\""); } From a44b374183ee7ac3455feb87fc5f9e69fed40bed Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:52:13 -0400 Subject: [PATCH 024/436] generic writeLine so color defaults properly --- src/PatternLab/Console/Commands/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 3da4fa2c..b47b4e97 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -50,7 +50,7 @@ public function run() { $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; $optionValue = (!$optionValue) ? "false" : $optionValue; $spacer = Console::getSpacer($lengthLong,strlen($optionName)); - Console::writeInfo($optionName.":".$spacer."".$optionValue.""); + Console::writeLine("".$optionName.":".$spacer.$optionValue); } } else if (Console::findCommandOption("get")) { From 9d6dd12ae7dc297b4e260f2bbec2db68add59e3e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:52:29 -0400 Subject: [PATCH 025/436] handle the "set" option --- .../Console/Commands/ConfigCommand.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index b47b4e97..9638aa0f 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -67,6 +67,26 @@ public function run() { } else if (Console::findCommandOption("set")) { + // find the value that was passed + $updateOption = Console::findCommandOptionValue("set"); + $updateOptionBits = explode("=",$updateOption); + if (count($updateOptionBits) == 1) { + Console::writeError("the --set option should look like optionName=\"optionValue\". nothing was updated..."); + } + + // set the name and value that were passed + $updateName = $updateOptionBits[0]; + $updateValue = (($updateOptionBits[1][0] == "\"") || ($updateOptionBits[1][0] == "'")) ? substr($updateOptionBits[1],1,strlen($updateOptionBits[1])-1) : $updateOptionBits[1]; + + // make sure the option being updated already exists + $currentValue = Config::getOption($updateName); + + if (!$currentValue) { + Console::writeError("the search config option you provided, ".$updateName.", does not exists in the config..."); + } else { + Config::updateConfigOption($updateName,$updateValue); + } + } else { } From 1abab49ceb6ceaeacba85c77a90b099e8c548db7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:52:45 -0400 Subject: [PATCH 026/436] write out help if no valid option was passed --- src/PatternLab/Console/Commands/ConfigCommand.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 9638aa0f..ae047fef 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -89,6 +89,9 @@ public function run() { } else { + // no acceptable options were passed so write out the help + Console::writeHelpCommand($this->command); + } } From fe7151c76f6950eabb40edec4cd506e47a9e4c63 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 11:52:57 -0400 Subject: [PATCH 027/436] update inline docs --- src/PatternLab/Console/Commands/ConfigCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index ae047fef..763f147a 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -35,8 +35,10 @@ public function run() { if (Console::findCommandOption("list")) { + // get all of the options $options = Config::get(); + // sort 'em alphabetically ksort($options); // find length of longest option @@ -45,7 +47,7 @@ public function run() { $lengthLong = (strlen($optionName) > $lengthLong) ? strlen($optionName) : $lengthLong; } - // iterate over each option + // iterate over each option and spit it out foreach ($options as $optionName => $optionValue) { $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; $optionValue = (!$optionValue) ? "false" : $optionValue; @@ -55,8 +57,11 @@ public function run() { } else if (Console::findCommandOption("get")) { + // figure out which optino was passed $searchOption = Console::findCommandOptionValue("get"); $optionValue = Config::getOption($searchOption); + + // write it out if (!$optionValue) { Console::writeError("the search config option you provided, ".$searchOption.", does not exists in the config..."); } else { From 19b3b99e13bda6796413942c4e18105b729dd316 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 13:26:06 -0400 Subject: [PATCH 028/436] updating copy --- src/PatternLab/Console/Commands/ConfigCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 763f147a..706115ab 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -63,7 +63,7 @@ public function run() { // write it out if (!$optionValue) { - Console::writeError("the search config option you provided, ".$searchOption.", does not exists in the config..."); + Console::writeError("the --get value you provided, ".$searchOption.", does not exists in the config..."); } else { $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; $optionValue = (!$optionValue) ? "false" : $optionValue; @@ -76,7 +76,7 @@ public function run() { $updateOption = Console::findCommandOptionValue("set"); $updateOptionBits = explode("=",$updateOption); if (count($updateOptionBits) == 1) { - Console::writeError("the --set option should look like optionName=\"optionValue\". nothing was updated..."); + Console::writeError("the --set value should look like optionName=\"optionValue\". nothing was updated..."); } // set the name and value that were passed @@ -87,7 +87,7 @@ public function run() { $currentValue = Config::getOption($updateName); if (!$currentValue) { - Console::writeError("the search config option you provided, ".$updateName.", does not exists in the config..."); + Console::writeError("the --set option you provided, ".$updateName.", does not exists in the config. nothing will be updated..."); } else { Config::updateConfigOption($updateName,$updateValue); } From d6fe3718c757f02f63458a9dc3147821bfc17bf1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 13:31:43 -0400 Subject: [PATCH 029/436] updating to use writeInfo() --- src/PatternLab/Console/Commands/VersionCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/VersionCommand.php b/src/PatternLab/Console/Commands/VersionCommand.php index 36ffb1a8..c85b7bff 100644 --- a/src/PatternLab/Console/Commands/VersionCommand.php +++ b/src/PatternLab/Console/Commands/VersionCommand.php @@ -29,7 +29,7 @@ public function __construct() { public function run() { - print "you're running v".Config::getOption("v")." of the PHP version of Pattern Lab...\n"; + Console::writeInfo("you're running v".Config::getOption("v")." of the PHP version of Pattern Lab..."); } From dd1db7a71640d9219af4ed795e5b003a115f4a7b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 15:39:37 -0400 Subject: [PATCH 030/436] centralizing prompting for a console input --- src/PatternLab/Console.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 34406826..19dcbb0b 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -495,4 +495,39 @@ public static function writeWarning($line,$doubleSpace = false,$doubleBreak = fa self::writeLine($lineFinal,$doubleSpace,$doubleBreak); } + /** + * Prompt the user for some input + * @param {String} the text for the prompt + * @param {String} the text for the options + * @param {Boolean} if we should lowercase the input before sending it back + * @param {String} the tag that should be used when drawing the content + * + * @return {String} trimmed input given by the user + */ + public static function promptInput($prompt = "", $options = "", $lowercase = true, $tag = "info") { + + // check prompt + if (empty($prompt)) { + Console::writeError("an input prompt requires prompt text..."); + } + + // if there are suggested options add them + if (!empty($options)) { + $prompt .= " ".$options." >"; + } + + // make sure no end-of-line is added + $prompt .= " "; + + // open the terminal and wait for feedback + $stdin = fopen("php://stdin", "r"); + Console::writeTag($output,$tag); + $input = trim(fgets($stdin)); + fclose($stdin); + + // check to see if it should be lowercased before sending back + return ($lowercase) ? strtolower($input) : $input; + + } + } From 1e7dd492a79781bad6ff41c4431f1a438bd7bf48 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 15:40:01 -0400 Subject: [PATCH 031/436] using promptInput for the config override --- src/PatternLab/Config.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 2a397474..a310c2ae 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -272,13 +272,10 @@ public static function updateConfigOption($optionName,$optionValue) { } else if (self::$options["overrideConfig"] == "q") { - // if the option is to query the user when the option is set do so - $output = "update the config option ".$optionName." with the value ".$optionValue."? Y/n > "; - - $stdin = fopen("php://stdin", "r"); - Console::writeLine($output); - $input = strtolower(trim(fgets($stdin))); - fclose($stdin); + // prompt for input + $prompt = "update the config option ".$optionName." with the value ".$optionValue."?"; + $options = "Y/n" + $input = Console::promptInput($prompt,$options); if ($input == "y") { self::writeUpdateConfigOption($optionName,$optionValue); From 00e49016e1d5f3393e7cf3ceb50a4db070c88f6a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 15:58:53 -0400 Subject: [PATCH 032/436] quick bug fixes --- src/PatternLab/Config.php | 2 +- src/PatternLab/Console.php | 2 +- src/PatternLab/Fetch.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index a310c2ae..fef0647e 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -274,7 +274,7 @@ public static function updateConfigOption($optionName,$optionValue) { // prompt for input $prompt = "update the config option ".$optionName." with the value ".$optionValue."?"; - $options = "Y/n" + $options = "Y/n"; $input = Console::promptInput($prompt,$options); if ($input == "y") { diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 19dcbb0b..0a9903da 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -521,7 +521,7 @@ public static function promptInput($prompt = "", $options = "", $lowercase = tru // open the terminal and wait for feedback $stdin = fopen("php://stdin", "r"); - Console::writeTag($output,$tag); + Console::writeTag($tag,$prompt); $input = trim(fgets($stdin)); fclose($stdin); diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 7094d336..3c46ceef 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -31,7 +31,7 @@ public function fetch($package = "") { } // run composer - $composerPath = Config::$option["coreDir"].DIRECTORY_SEPARATOR."bin/composer.phar"; + $composerPath = Config::getOption("coreDir").DIRECTORY_SEPARATOR."bin/composer.phar"; passthru("php ".$composerPath." require ".$package); } From 6f61b417ca531496a450ee57e83aa715184497b6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 15:59:13 -0400 Subject: [PATCH 033/436] fetch package now supports a prompt call --- .../Console/Commands/FetchCommand.php | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/Console/Commands/FetchCommand.php b/src/PatternLab/Console/Commands/FetchCommand.php index 1f87da6c..c2c9157f 100644 --- a/src/PatternLab/Console/Commands/FetchCommand.php +++ b/src/PatternLab/Console/Commands/FetchCommand.php @@ -24,17 +24,41 @@ public function __construct() { $this->command = "fetch:"; - Console::setCommand($this->command,"Fetch a package","The fetch command grabs a package from GitHub and installs the package and any package dependencies.","f:"); - Console::setCommandSample($this->command,"To fetch a package:",""); + Console::setCommand($this->command,"Fetch a package","The fetch command loads a package and its dependencies from Packagist.","f:"); + Console::setCommandSample($this->command,"To fetch a package from Packagist:",""); } public function run() { - // run the fetch command - $p = Console::findCommandValue("f|fetch"); - $f = new Fetch(); - $f->fetch($p); + // find the value given to the command + $package = Console::findCommandValue("f|fetch"); + + if ($package) { + + // if was passed ask the user for the package name + if ($package == "prompt") { + $prompt = "what is the name of the package you want to fetch?"; + $options = "(ex. pattern-lab/plugin-kss)"; + $package = Console::promptInput($prompt,$options); + } + + // make sure it looks like a valid package + if (strpos($package,"/") === false) { + Console::writeError("that wasn't a valid package name. it should look like pattern-lab/plugin-kss..."); + } + + // run composer via fetch + $f = new Fetch(); + $f->fetch($package); + + } else { + + Console::writeHelpCommand($this->command); + + } + + } From 7172c2e96cdfd6e0b35ad05b5322379ed914e244 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 16:26:31 -0400 Subject: [PATCH 034/436] updating sourceDir use --- src/PatternLab/Annotations.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 46b11fb6..51dd61b8 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -31,6 +31,8 @@ class Annotations { */ public static function gather() { + // set-up default var + $sourceDir = Config::getOption("sourceDir"); // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); @@ -44,8 +46,9 @@ public static function gather() { if (!is_dir(Config::getOption("sourceDir")."/_annotations")) { Console::writeLine("_annotations/ doesn't exist so you won't have annotations..."); exit; + if (!is_dir($sourceDir."/_annotations")) { } - $directoryIterator = new \RecursiveDirectoryIterator(Config::getOption("sourceDir")."/_annotations"); + $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_annotations"); $objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); // make sure dots are skipped @@ -84,8 +87,8 @@ public static function gather() { } // read in the old style annotations.js, modify the data and generate JSON array to merge - if (file_exists(Config::getOption("sourceDir")."/_annotations/annotations.js")) { - $text = file_get_contents(Config::getOption("sourceDir")."/_annotations/annotations.js"); + if (file_exists($sourceDir."/_annotations/annotations.js")) { + $text = file_get_contents($sourceDir."/_annotations/annotations.js"); $text = str_replace("var comments = ","",$text); $text = rtrim($text,";"); $data = json_decode($text,true); From 18adcd4453b8730b077a59be61e3e79b9b532a2c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 16:26:43 -0400 Subject: [PATCH 035/436] making annotations dir if it doesn't exist --- src/PatternLab/Annotations.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 51dd61b8..cbb866c8 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -47,6 +47,7 @@ public static function gather() { Console::writeLine("_annotations/ doesn't exist so you won't have annotations..."); exit; if (!is_dir($sourceDir."/_annotations")) { + mkdir($sourceDir."/_annotations"); } $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_annotations"); $objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); From b37f4cb2ad4489ce1484b20a02da1a9710c68036 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 16:27:05 -0400 Subject: [PATCH 036/436] making the _data dir if it doesn't exist --- src/PatternLab/Data.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 424d4ffe..50796f15 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -55,6 +55,7 @@ public static function gather($options = array()) { if (!is_dir($sourceDir."/_data/")) { Console::writeLine("_data/ doesn't exist so you won't have dynamic data..."); exit; + mkdir($sourceDir."/_data/"); } $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_data/"); $objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); From cc63b6f0d6ec952b58fb65726e07e1ac3d54aeef Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 16:27:24 -0400 Subject: [PATCH 037/436] updating the console::write calls --- src/PatternLab/Annotations.php | 4 +--- src/PatternLab/Config.php | 22 +++++++++---------- src/PatternLab/Data.php | 5 ++--- src/PatternLab/Dispatcher.php | 3 +-- src/PatternLab/Fetch.php | 3 +-- src/PatternLab/FileUtil.php | 2 +- src/PatternLab/Generator.php | 3 +-- src/PatternLab/InstallerUtil.php | 6 ++--- src/PatternLab/JSON.php | 2 +- .../PatternData/Helpers/LineageHelper.php | 2 +- src/PatternLab/PatternEngine.php | 6 ++--- src/PatternLab/Template.php | 11 ++++------ src/PatternLab/Timer.php | 6 ++--- src/PatternLab/Util.php | 3 +-- src/PatternLab/Watcher.php | 3 +-- 15 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index cbb866c8..51b95d16 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -43,10 +43,8 @@ public static function gather() { self::$store["comments"] = array(); // iterate over all of the files in the annotations dir - if (!is_dir(Config::getOption("sourceDir")."/_annotations")) { - Console::writeLine("_annotations/ doesn't exist so you won't have annotations..."); - exit; if (!is_dir($sourceDir."/_annotations")) { + Console::writeWarning("_annotations/ doesn't exist so you won't have annotations..."); mkdir($sourceDir."/_annotations"); } $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_annotations"); diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index fef0647e..96b83f15 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -82,7 +82,7 @@ public static function init($baseDir = "", $verbose = true) { // make sure a base dir was supplied if (empty($baseDir)) { - Console::writeLine("need a base directory to initialize the config class..."); exit; + Console::writeError("need a base directory to initialize the config class..."); } // normalize the baseDir @@ -113,13 +113,12 @@ public static function init($baseDir = "", $verbose = true) { // double-check the default config file exists if (!file_exists(self::$plConfigPath)) { - Console::writeLine("make sure config.ini.default exists before trying to have Pattern Lab build the config.ini file automagically..."); exit; + Console::writeError("make sure config.ini.default exists before trying to have Pattern Lab build the config.ini file automagically..."); } // set the default config using the pattern lab config if (!self::$options = @parse_ini_file(self::$plConfigPath)) { - Console::writeLine("Config parse error in ".self::$plConfigPath."..."); - exit; + Console::writeError("Config parse error in ".self::$plConfigPath."..."); } // make sure these are copied @@ -134,8 +133,7 @@ public static function init($baseDir = "", $verbose = true) { $migrate = true; } else { if (!self::$options = @parse_ini_file(self::$userConfigPath)) { - Console::writeLine("Config parse error in ".self::$userConfigPath."..."); - exit; + Console::writeError("Config parse error in ".self::$userConfigPath."..."); } } @@ -145,11 +143,11 @@ public static function init($baseDir = "", $verbose = true) { // run an upgrade and migrations if necessary if ($migrate || $diffVersion) { if ($verbose) { - Console::writeLine("upgrading your version of pattern lab..."); + Console::writeInfo("upgrading your version of pattern lab..."); } if ($migrate) { if (!@copy(self::$plConfigPath, self::$userConfigPath)) { - Console::writeLine("make sure that Pattern Lab can write a new config to ".self::$userConfigPath."..."); + Console::writeError("make sure that Pattern Lab can write a new config to ".self::$userConfigPath."..."); exit; } } else { @@ -159,7 +157,7 @@ public static function init($baseDir = "", $verbose = true) { // making sure the config isn't empty if (empty(self::$options) && $verbose) { - Console::writeLine("a set of configuration options is required to use Pattern Lab..."); + Console::writeError("a set of configuration options is required to use Pattern Lab..."); exit; } @@ -263,7 +261,7 @@ public static function updateConfigOption($optionName,$optionValue) { fclose($stdin); self::writeUpdateConfigOption($optionName,$input); - Console::writeLine("config option ".$optionName." updated...", false, true); + Console::writeTag("ok","config option ".$optionName." updated...", false, true); } else if (!isset(self::$options[$optionName]) || (self::$options["overrideConfig"] == "a")) { @@ -279,9 +277,9 @@ public static function updateConfigOption($optionName,$optionValue) { if ($input == "y") { self::writeUpdateConfigOption($optionName,$optionValue); - Console::writeLine("config option ".$optionName." updated...", false, true); + Console::writeInfo("config option ".$optionName." updated...", false, true); } else { - Console::writeLine("config option ".$optionName." not updated...", false, true); + Console::writeWarning("config option ".$optionName." not updated...", false, true); } } diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 50796f15..4934d531 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -53,8 +53,7 @@ public static function gather($options = array()) { // iterate over all of the other files in the source directory if (!is_dir($sourceDir."/_data/")) { - Console::writeLine("_data/ doesn't exist so you won't have dynamic data..."); - exit; + Console::writeWarning("_data/ doesn't exist so you won't have dynamic data..."); mkdir($sourceDir."/_data/"); } $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_data/"); @@ -124,7 +123,7 @@ public static function gather($options = array()) { if (is_array(self::$store)) { foreach (self::$reservedKeys as $reservedKey) { if (array_key_exists($reservedKey,self::$store)) { - Console::writeLine("\"".$reservedKey."\" is a reserved key in Pattern Lab. the data using that key will be overwritten. please choose a new key..."); + Console::writeWarning("\"".$reservedKey."\" is a reserved key in Pattern Lab. the data using that key will be overwritten. please choose a new key..."); } } } diff --git a/src/PatternLab/Dispatcher.php b/src/PatternLab/Dispatcher.php index a6089d20..10e1aff1 100644 --- a/src/PatternLab/Dispatcher.php +++ b/src/PatternLab/Dispatcher.php @@ -50,8 +50,7 @@ protected static function loadListeners() { // see if the package dir exists. if it doesn't it means composer hasn't been run if (!is_dir($packagesDir)) { - Console::writeLine("you haven't fully set-up Pattern Lab yet. please add a pattern engine..."); - exit; + Console::writeError("you haven't fully set-up Pattern Lab yet. please add a pattern engine..."); } // make sure the listener data exists diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 3c46ceef..58afe302 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -26,8 +26,7 @@ class Fetch { public function fetch($package = "") { if (empty($package)) { - Console::writeLine("please provide a path for the package before trying to fetch it..."); - exit; + Console::writeError("please provide a path for the package before trying to fetch it..."); } // run composer diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index ad7748a7..1b319740 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -49,7 +49,7 @@ public static function moveStaticFile($fileName,$copy = "", $find = "", $replace self::moveFile($fileName,str_replace($find, $replace, $fileName)); Util::updateChangeTime(); if ($copy != "") { - Console::writeLine($fileName." ".$copy."..."); + Console::writeInfo($fileName." ".$copy."..."); } } diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index c4ffbcc6..afc63df0 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -44,8 +44,7 @@ public function generate($options = array()) { // double-checks options was properly set if (empty($options)) { - Console::writeLine("need to pass options to generate..."); - exit; + Console::writeError("need to pass options to generate..."); } // set the default vars diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 81a2e951..f6aa7759 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -125,14 +125,14 @@ protected static function pathExists($packageName,$path) { if ($prompt) { $stdin = fopen("php://stdin", "r"); - Console::writeLine("the path ".$path." already exists. overwrite it with the contents of ".$packageName."? Y/n > "); + Console::writeInfo("the path ".$path." already exists. overwrite it with the contents of ".$packageName."? Y/n > "); $answer = strtolower(trim(fgets($stdin))); fclose($stdin); if ($answer == "y") { - Console::writeLine("contents of ".$path." being overwritten...", false, false); + Console::writeTag("ok","contents of ".$path." being overwritten...", false, false); return false; } else { - Console::writeLine("contents of ".$path." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, false); + Console::writeWarning("contents of ".$path." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, false); return true; } } diff --git a/src/PatternLab/JSON.php b/src/PatternLab/JSON.php index 71cc45ba..95acb512 100644 --- a/src/PatternLab/JSON.php +++ b/src/PatternLab/JSON.php @@ -47,7 +47,7 @@ public static function lastErrorMsg($file,$message,$data) { Console::writeLine(""); $parser = new JsonLint\JsonParser(); $error = $parser->lint($data); - Console::writeLine("".$error->getMessage()."", false, true); + Console::writeError($error->getMessage(), false, true); } } diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 5d559f7a..86832c39 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -58,7 +58,7 @@ public function run() { } else { if (strpos($lineage, '/') === false) { - Console::writeLine("you may have a typo in ".$fileName.". {{> ".$lineage." }} is not a valid pattern..."); + Console::writeWarning("you may have a typo in ".$fileName.". {{> ".$lineage." }} is not a valid pattern..."); } } diff --git a/src/PatternLab/PatternEngine.php b/src/PatternLab/PatternEngine.php index bbc17018..b08b9a6e 100644 --- a/src/PatternLab/PatternEngine.php +++ b/src/PatternLab/PatternEngine.php @@ -45,8 +45,7 @@ public static function init() { } if (!$found) { - Console::writeLine("the supplied pattern extension didn't match a pattern loader rule..."); - exit; + Console::writeError("the supplied pattern extension didn't match a pattern loader rule..."); } } @@ -61,8 +60,7 @@ public static function loadRules() { // see if the package dir exists. if it doesn't it means composer hasn't been run if (!is_dir($packagesDir)) { - Console::writeLine("you haven't fully set-up Pattern Lab yet. please add a pattern engine..."); - exit; + Console::writeError("you haven't fully set-up Pattern Lab yet. please add a pattern engine..."); } // make sure the pattern engine data exists diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index 12cbcfd5..cd0a072f 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -33,13 +33,11 @@ public static function init() { // make sure config vars exist if (!Config::getOption("patternExtension")) { - Console::writeLine("the pattern extension config option needs to be set..."); - exit; + Console::writeError("the pattern extension config option needs to be set..."); } if (!Config::getOption("styleguideKit")) { - Console::writeLine("the styleguideKit config option needs to be set..."); - exit; + Console::writeError("the styleguideKit config option needs to be set..."); } // set-up config vars @@ -116,9 +114,8 @@ public static function getHTMLLoader() { public static function getPatternLoader() { if (empty(self::$patternLoader)) { - Console::writeLine("pattern loader needs to be set before you can get it..."); - Console::writeLine('try this first: Template::setPatternLoader(PatternEngine::getInstance()->getPatternLoader($options));'); - exit; + Console::writeTag("error","pattern loader needs to be set before you can get it..."); + Console::writeError("try this first: Template::setPatternLoader(PatternEngine::getInstance()->getPatternLoader($options));"); } return self::$patternLoader; diff --git a/src/PatternLab/Timer.php b/src/PatternLab/Timer.php index 47b53d45..064d333e 100644 --- a/src/PatternLab/Timer.php +++ b/src/PatternLab/Timer.php @@ -26,8 +26,7 @@ public static function check($text = "") { // make sure start time is set if (empty(self::$startTime)) { - Console::writeLine("the timer wasn't started..."); - exit; + Console::writeError("the timer wasn't started..."); } // make sure check time is set @@ -91,8 +90,7 @@ public static function stop() { // make sure start time is set if (empty(self::$startTime)) { - Console::writeLine("the timer wasn't started..."); - exit; + Console::writeError("the timer wasn't started..."); } // get the current time diff --git a/src/PatternLab/Util.php b/src/PatternLab/Util.php index f7a125a0..9efc488f 100644 --- a/src/PatternLab/Util.php +++ b/src/PatternLab/Util.php @@ -65,8 +65,7 @@ public static function updateChangeTime() { if (is_dir(Config::getOption("publicDir"))) { file_put_contents(Config::getOption("publicDir")."/latest-change.txt",time()); } else { - Console::writeLine("the public directory for Pattern Lab doesn't exist..."); - exit; + Console::writeError("the public directory for Pattern Lab doesn't exist..."); } } diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index efc08414..951b28f8 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -47,8 +47,7 @@ public function watch($options = array()) { // double-checks options was properly set if (empty($options)) { - Console::writeLine("need to pass options to generate..."); - exit; + Console::writeError("need to pass options to generate..."); } // set default attributes From be8d17d3127a0a415ed7bc635925c76787c4f933 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 16:33:45 -0400 Subject: [PATCH 038/436] updating to console::promptInput --- src/PatternLab/Config.php | 11 ++++------- src/PatternLab/InstallerUtil.php | 11 +++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 96b83f15..d3efd1f0 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -252,13 +252,10 @@ public static function updateConfigOption($optionName,$optionValue) { if (strpos($optionValue,"") !== false) { - // if this is a prompt always write out the query - $output = str_replace("","",str_replace("","",$optionValue)).""; - - $stdin = fopen("php://stdin", "r"); - Console::writeLine($output); - $input = strtolower(trim(fgets($stdin))); - fclose($stdin); + // prompt for input using the supplied query + $prompt = str_replace("","",str_replace("","",$optionValue)); + $options = ""; + $input = Console::promptInput($prompt,$options,false); self::writeUpdateConfigOption($optionName,$input); Console::writeTag("ok","config option ".$optionName." updated...", false, true); diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index f6aa7759..d4c28227 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -124,10 +124,12 @@ protected static function pathExists($packageName,$path) { } if ($prompt) { - $stdin = fopen("php://stdin", "r"); - Console::writeInfo("the path ".$path." already exists. overwrite it with the contents of ".$packageName."? Y/n > "); - $answer = strtolower(trim(fgets($stdin))); - fclose($stdin); + + // prompt for input using the supplied query + $prompt = "the path ".$path." already exists. overwrite it with the contents of ".$packageName."?"; + $options = "Y/n"; + $input = Console::promptInput($prompt,$options); + if ($answer == "y") { Console::writeTag("ok","contents of ".$path." being overwritten...", false, false); return false; @@ -135,6 +137,7 @@ protected static function pathExists($packageName,$path) { Console::writeWarning("contents of ".$path." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, false); return true; } + } return false; From 6554ba4ca461d98ba4720ce54fab09d1c622619b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 16:37:09 -0400 Subject: [PATCH 039/436] making sure the check matches the name of the return var --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index d4c28227..17c10466 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -130,7 +130,7 @@ protected static function pathExists($packageName,$path) { $options = "Y/n"; $input = Console::promptInput($prompt,$options); - if ($answer == "y") { + if ($input == "y") { Console::writeTag("ok","contents of ".$path." being overwritten...", false, false); return false; } else { From 880920ad8bb9f63094fa9527de80f412cae721a1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 17:08:47 -0400 Subject: [PATCH 040/436] making sure false isn't always returned --- src/PatternLab/Data.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 4934d531..3527b007 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -331,6 +331,7 @@ public static function setPatternData($optionName,$optionValue) { if (isset(self::$store["patternSpecific"][$optionName])) { self::$store["patternSpecific"][$optionName]["data"] = $optionValue; + return true; } return false; @@ -346,6 +347,7 @@ public static function setPatternListItems($optionName,$optionValue) { if (isset(self::$store["patternSpecific"][$optionName])) { self::$store["patternSpecific"][$optionName]["listItems"] = $optionValue; + return true; } return false; From 676a88c75727bd8dc0bd3a2b3c5c267a879b0bf1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 21:21:52 -0400 Subject: [PATCH 041/436] adding finder as a dependency --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 414bb472..c52de10e 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "seld/jsonlint": "1.1.2", "symfony/event-dispatcher": "v2.5.0", "symfony/filesystem": "v2.5.0", + "symfony/finder": "v2.5.3", "kevinlebrun/colors.php": "0.*", "pattern-lab/unified-asset-installer": "dev-dev" } From 2913b8440421c7ca28e7e5be8d70c544abb70aff Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 21:22:04 -0400 Subject: [PATCH 042/436] componentDir support --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index d3efd1f0..53a30016 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -170,6 +170,7 @@ public static function init($baseDir = "", $verbose = true) { self::$options["publicDir"] = isset(self::$options["publicDir"]) ? $baseFull.self::cleanDir(self::$options["publicDir"]) : $baseFull."public"; self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? $baseFull.self::cleanDir(self::$options["scriptsDir"]) : $baseFull."scripts"; self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? $baseFull.self::cleanDir(self::$options["sourceDir"]) : $baseFull."source"; + self::$options["componentDir"] = self::$options["publicDir"]."/patternlab-components"; self::$options["dataDir"] = self::$options["sourceDir"]."/_data"; self::$options["patternExportDir"] = self::$options["exportDir"]."/patterns"; self::$options["patternPublicDir"] = self::$options["publicDir"]."/patterns"; From cd4f2499aaa358b2cea700a2266dbc4a2daa1061 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Aug 2014 21:22:21 -0400 Subject: [PATCH 043/436] break when item is found --- src/PatternLab/InstallerUtil.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 17c10466..9c8b5f74 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -358,6 +358,8 @@ protected static function scanForListener($pathPackage,$remove = false) { // write out the listener list file_put_contents($pathList,json_encode($listenerList)); + break; + } } @@ -407,6 +409,8 @@ protected static function scanForPatternEngineRule($pathPackage,$remove = false) // write out the pattern engine list file_put_contents($pathList,json_encode($patternEngineList)); + break; + } } From 0b2c92e6df7681d3105a6fb009447e597f0ad93b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 09:37:41 -0500 Subject: [PATCH 044/436] adding proper exit code on an error --- src/PatternLab/Console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 0a9903da..7c1ef005 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -441,7 +441,7 @@ public static function addTags($line,$tag) { public static function writeError($line,$doubleSpace = false,$doubleBreak = false) { $lineFinal = self::addTags($line,"error"); self::writeLine($lineFinal,$doubleSpace,$doubleBreak); - exit; + exit(1); } /** From 779851d802ed1860ca57a51fbd8d9abbef7adba0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 09:38:03 -0500 Subject: [PATCH 045/436] removing unnecessary lines --- src/PatternLab/Timer.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/PatternLab/Timer.php b/src/PatternLab/Timer.php index 064d333e..068504aa 100644 --- a/src/PatternLab/Timer.php +++ b/src/PatternLab/Timer.php @@ -113,6 +113,4 @@ public static function stop() { } - - } \ No newline at end of file From ab35930e4b1f0b824c960152850b9c4311eff2c3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 11:39:21 -0500 Subject: [PATCH 046/436] moving the timer call --- src/PatternLab/Annotations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 51b95d16..78393823 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -16,9 +16,9 @@ use \PatternLab\Console; use \PatternLab\Dispatcher; use \PatternLab\Parsers\Documentation; +use \PatternLab\Timer; use \Symfony\Component\Yaml\Exception\ParseException; use \Symfony\Component\Yaml\Yaml; -use \PatternLab\Timer; class Annotations { From 43621f1774944763d3ff7c049594cb0823599230 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 11:40:24 -0500 Subject: [PATCH 047/436] adding support for symfony's finder where it makes sense --- src/PatternLab/Annotations.php | 50 +++-- src/PatternLab/Builder.php | 25 +-- src/PatternLab/Data.php | 20 +- src/PatternLab/InstallerUtil.php | 312 ++++++++++++++++++++++--------- 4 files changed, 264 insertions(+), 143 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 78393823..d5bb4a82 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -17,6 +17,7 @@ use \PatternLab\Dispatcher; use \PatternLab\Parsers\Documentation; use \PatternLab\Timer; +use \Symfony\Component\Finder\Finder; use \Symfony\Component\Yaml\Exception\ParseException; use \Symfony\Component\Yaml\Yaml; @@ -47,39 +48,34 @@ public static function gather() { Console::writeWarning("_annotations/ doesn't exist so you won't have annotations..."); mkdir($sourceDir."/_annotations"); } - $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_annotations"); - $objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); + // find the markdown-based annotations + $finder = new Finder(); + $finder->files()->name("*.md")->in($sourceDir."/_annotations"); + $finder->sortByName(); - foreach ($objects as $name => $object) { - - // if it's an .md file parse and generate the proper info - if ($object->isFile() && ($object->getExtension() == "md")) { - - $data = array(); - $data[0] = array(); + foreach ($finder as $name => $file) { - $text = file_get_contents($object->getPathname()); + $data = array(); + $data[0] = array(); + + $text = file_get_contents($file->getPathname()); + + $matches = (strpos($text,PHP_EOL."~*~".PHP_EOL) !== false) ? explode(PHP_EOL."~*~".PHP_EOL,$text) : array($text); + + foreach ($matches as $match) { - $matches = (strpos($text,PHP_EOL."~*~".PHP_EOL) !== false) ? explode(PHP_EOL."~*~".PHP_EOL,$text) : array($text); + list($yaml,$markdown) = Documentation::parse($match); - foreach ($matches as $match) { - - list($yaml,$markdown) = Documentation::parse($match); - - if (isset($yaml["el"]) || isset($yaml["selector"])) { - $data[0]["el"] = (isset($yaml["el"])) ? $yaml["el"] : $yaml["selector"]; - } else { - $data[0]["el"] = "#someimpossibleselector"; - } - $data[0]["title"] = isset($yaml["title"]) ? $yaml["title"] : ""; - $data[0]["comment"] = $markdown; - - self::$store["comments"] = array_merge(self::$store["comments"],$data); - + if (isset($yaml["el"]) || isset($yaml["selector"])) { + $data[0]["el"] = (isset($yaml["el"])) ? $yaml["el"] : $yaml["selector"]; + } else { + $data[0]["el"] = "#someimpossibleselector"; } + $data[0]["title"] = isset($yaml["title"]) ? $yaml["title"] : ""; + $data[0]["comment"] = $markdown; + + self::$store["comments"] = array_merge(self::$store["comments"],$data); } diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 416bb30c..6c403102 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -25,6 +25,7 @@ use \PatternLab\Render; use \PatternLab\Template; use \PatternLab\Timer; +use \Symfony\Component\Finder\Finder; class Builder { @@ -53,24 +54,18 @@ protected function gatherMQs() { $mqs = array(); // iterate over all of the other files in the source directory - $directoryIterator = new \RecursiveDirectoryIterator(Config::getOption("sourceDir")); - $objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); + $finder = new Finder(); + $finder->files()->name("*.css")->in(Config::getOption("sourceDir")); + $finder->sortByName(); - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); - - foreach ($objects as $name => $object) { + foreach ($finder as $file) { - if ($object->isFile() && ($object->getExtension() == "css")) { - - $data = file_get_contents($object->getPathname()); - preg_match_all("/(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches); - foreach ($matches[3] as $match) { - if (!in_array($match,$mqs)) { - $mqs[] = $match; - } + $data = file_get_contents($file->getPathname()); + preg_match_all("/(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches); + foreach ($matches[3] as $match) { + if (!in_array($match,$mqs)) { + $mqs[] = $match; } - } } diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 3527b007..18d49a65 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -16,6 +16,7 @@ use \PatternLab\Console; use \PatternLab\Dispatcher; use \PatternLab\Timer; +use \Symfony\Component\Finder\Finder; use \Symfony\Component\Yaml\Exception\ParseException; use \Symfony\Component\Yaml\Yaml; @@ -56,24 +57,23 @@ public static function gather($options = array()) { Console::writeWarning("_data/ doesn't exist so you won't have dynamic data..."); mkdir($sourceDir."/_data/"); } - $directoryIterator = new \RecursiveDirectoryIterator($sourceDir."/_data/"); - $objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST); - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); + // find the markdown-based annotations + $finder = new Finder(); + $finder->files()->in($sourceDir."/_data/"); + $finder->sortByName(); - foreach ($objects as $name => $object) { + foreach ($finder as $name => $file) { - $ext = $object->getExtension(); + $ext = $file->getExtension(); $data = array(); - $fileName = $object->getFilename(); + $fileName = $file->getFilename(); $hidden = ($fileName[0] == "_"); - $isFile = $object->isFile(); $isListItems = strpos("listitems",$fileName); - $pathName = $object->getPathname(); + $pathName = $file->getPathname(); $pathNameClean = str_replace($sourceDir."/","",$pathName); - if ($isFile && !$hidden && (($ext == "json") || ($ext == "yaml"))) { + if (!$hidden && (($ext == "json") || ($ext == "yaml"))) { if ($isListItems === false) { diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 9c8b5f74..7d5b65ee 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -17,9 +17,35 @@ use \PatternLab\Timer; use \Symfony\Component\Filesystem\Filesystem; use \Symfony\Component\Filesystem\Exception\IOExceptionInterface; +use \Symfony\Component\Finder\Finder; class InstallerUtil { + protected static $fs; + + /** + * Move the component files from the package to their location in the patternlab-components dir + * @param {String/Array} the items to create a fileList for + * + * @return {Array} list of files destination and source + */ + protected static function buildFileList($initialList) { + + $fileList = array(); + + // see if it's an array. loop over the multiple items if it is + if (is_array($initialList)) { + foreach ($initialList as $listItem) { + $fileList[$listItem] = $listItem; + } + } else { + $fileList[$listItem] = $listItem; + } + + return $fileList; + + } + /** * Common init sequence */ @@ -32,6 +58,144 @@ protected static function init() { $baseDir = __DIR__."/../../../../../"; Config::init($baseDir,false); + // load the file system function + self::$fs = new Filesystem(); + } + + /** + * Parse the component types to figure out what needs to be moved and added to the component JSON files + * @param {String} file path to move + * @param {String} file path to move to + * @param {String} the name of the package + * @param {String} the base directory for the source of the files + * @param {String} the base directory for the destination of the files (publicDir or sourceDir) + * @param {Array} the list of files to be moved + */ + protected static function moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase) { + + // make sure the destination base exists + if (!is_dir($destinationBase)) { + mkdir($destinationBase); + } + + // clean any * or / on the end of $destination + $destination = ($destination[strlen($destination)-1] == "*") ? substr($destination,0,-1) : $destination; + $destination = ($destination[strlen($destination)-1] == "/") ? substr($destination,0,-1) : $destination; + + // decide how to move the files. the rules: + // dest ~ src -> action + // * ~ * -> mirror to path/ + // path ~ * -> mirror to path/ + // path ~ foo/* -> mirror to path/foo + // path ~ foo/s.html -> copy tp path/foo/s.html + + if (($source == "*") && ($destination == "*")) { + if (!self::pathExists($packageName,$destinationBase."/")) { + self::$fs->mirror($sourceBase,$destinationBase."/"); + } + } else if ($source == "*") { + if (!self::pathExists($packageName,$destinationBase."/".$destination)) { + self::$fs->mirror($sourceBase,$destinationBase."/".$destination); + } + } else if ($source[strlen($source)-1] == "*") { + $source = rtrim($source,"/*"); + if (!self::pathExists($packageName,$destinationBase."/".$destination)) { + self::$fs->mirror($sourceBase.$source,$destinationBase."/".$destination); + } + } else { + $pathInfo = explode("/",$destination); + $file = array_pop($pathInfo); + $destinationDir = implode("/",$pathInfo); + if (!self::$fs->exists($destinationBase."/".$destinationDir)) { + self::$fs->mkdir($destinationBase."/".$destinationDir); + } + if (!self::pathExists($packageName,$destinationBase."/".$destination)) { + self::$fs->copy($sourceBase.$source,$destinationBase."/".$destination,true); + } + } + + } + + /** + * Parse the component types to figure out what needs to be moved and added to the component JSON files + * @param {String} the name of the package + * @param {String} the base directory for the source of the files + * @param {String} the base directory for the destination of the files (publicDir or sourceDir) + * @param {Array} the list of files to be moved + */ + protected static function parseComponentTypes($packageName,$sourceBase,$destinationBase,$componentTypes) { + + /* + NEED TO KNOW TYPES BEFORE MOVING, they just get mirrored + "dist": { + "componentDir": { // patternlab-components/package/name/ + "css": "css/*", // string or array + "javascript": { // string, object, or array + "files": // string or array + "onready": // string + } + "images": // string or array + "templates": // string or array + } + */ + + /* + patternlab-components/templates.json (read in via PHP and written out as data.json), loaded via AJAX + for PHP: { "templates": [...] } + for JS: var templates = [ { "pattern-lab/plugin-kss": [ "dist/templates/foo.mustache "] } ]; + patternlab-components/javascript.json (read in via PHP and written out as data.json), $script uses the data.json to load the list of files + for PHP: { "javascript": [...] }; + for JS: var javascript = [ { "pattern-lab/plugin-kss": { "dependencies": [ "path.js" ], "onready": "code" } } ]; + patternlab-components/css.json (read in via PHP and written out as data.json), simple loader uses data.json to the load the list of files + for PHP: { "css": [...] }; + for JS: var css = [ { "pattern-lab/plugin-kss": [ "path1.css", "path2.css" ] } ]; + */ + + $destinationBase = $destinationBase."/".$packageName; + + // check if css option is set + if (isset($componentTypes["css"])) { + + $fileList = self::buildFileList($componentTypes["css"]); + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::updateComponentJSON("css",$componentTypes["css"]); + + } + + // check if the javascript option is set + if (isset($componentList["javascript"])) { + + // check to see if this has options + if (is_array($componentList["javascript"]) && (isset($componentTypes["javascript"]["files"]))) { + $fileList = self::buildFileList($componentList["javascript"]["files"]); + $javascriptList = $componentList["javascript"]["files"]; + } else { + $fileList = self::buildFileList($componentList["javascript"]); + $javascriptList = $componentList["javascript"]; + } + + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::updateComponentJSON("javascript",$javascriptList); + + } + + // check if the images option is set + if (isset($componentTypes["images"])) { + + $fileList = self::buildFileList($componentTypes["images"]); + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + + } + + // check if the templates option is set + if (isset($componentList["templates"])) { + + $fileList = self::buildFileList($componentTypes["templates"]); + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::updateComponentJSON("templates",$componentTypes["templates"]); + + } + } /** @@ -43,47 +207,22 @@ protected static function init() { */ protected static function parseFileList($packageName,$sourceBase,$destinationBase,$fileList) { - $fs = new Filesystem(); - foreach ($fileList as $fileItem) { // retrieve the source & destination - $source = self::removeDots(key($fileItem)); - $destination = self::removeDots($fileItem[$source]); - - // make sure the destination base exists - if (!is_dir($destinationBase)) { - mkdir($destinationBase); - } + $destination = self::removeDots(key($fileItem)); + $source = self::removeDots($fileItem[$destination]); // depending on the source handle things differently. mirror if it ends in /* - if (($source == "*") && ($destination == "*")) { - if (!self::pathExists($packageName,$destinationBase."/")) { - $fs->mirror($sourceBase,$destinationBase."/"); - } - } else if (($source == "*") && ($destination[strlen($source)-1] == "*")) { - $destination = rtrim($destination,"/*"); - if (!self::pathExists($packageName,$destinationBase."/".$destination)) { - $fs->mirror($sourceBase,$destinationBase."/".$destination); - } - } else if ($source[strlen($source)-1] == "*") { - $source = rtrim($source,"/*"); - $destination = rtrim($destination,"/*"); - if (!self::pathExists($packageName,$destinationBase."/".$destination)) { - $fs->mirror($sourceBase.$source,$destinationBase."/".$destination); + if (is_array($source)) { + foreach ($source as $key => $value) { + self::moveFiles($value,$key,$packageName,$sourceBase,$destinationBase); } } else { - $pathInfo = explode("/",$destination); - $file = array_pop($pathInfo); - $destinationDir = implode("/",$pathInfo); - if (!$fs->exists($destinationBase."/".$destinationDir)) { - $fs->mkdir($destinationBase."/".$destinationDir); - } - if (!self::pathExists($packageName,$destinationBase."/".$destination)) { - $fs->copy($sourceBase.$source,$destinationBase."/".$destination,true); - } + self::moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase); } + } } @@ -97,9 +236,7 @@ protected static function parseFileList($packageName,$sourceBase,$destinationBas */ protected static function pathExists($packageName,$path) { - $fs = new Filesystem(); - - if ($fs->exists($path)) { + if (self::$fs->exists($path)) { // set if the prompt should fire $prompt = true; @@ -154,6 +291,10 @@ protected static function pathExists($packageName,$path) { */ public static function postPackageInstall($event) { + // run the console and config inits + self::init(); + + // run the tasks based on what's in the extra dir self::runTasks($event,"install"); } @@ -164,6 +305,9 @@ public static function postPackageInstall($event) { */ public static function postPackageUpdate($event) { + // run the console and config inits + self::init(); + self::runTasks($event,"update"); } @@ -240,9 +384,6 @@ protected static function removeDots($path) { */ protected static function runTasks($event,$type) { - // run the console and config inits - self::init(); - // get package info $package = ($type == "install") ? $event->getOperation()->getPackage() : $event->getOperation()->getTargetPackage(); $extra = $package->getExtra(); @@ -282,7 +423,12 @@ protected static function runTasks($event,$type) { // move assets to the data directory if (isset($extra["dist"]["dataDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$extra["dist"]["scriptsDir"]); + self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$extra["dist"]["dataDir"]); + } + + // move assets to the components directory + if (isset($extra["dist"]["componentDir"])) { + self::parseComponentTypes($name,$pathDist,Config::getOption("componentDir")."/".$name,$extra["dist"]["componentDir"]); } // see if we need to modify the config @@ -332,36 +478,28 @@ protected static function scanForListener($pathPackage,$remove = false) { // load listener list $listenerList = json_decode(file_get_contents($pathList),true); - // grab the list of files in the package - $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pathPackage), \RecursiveIteratorIterator::CHILD_FIRST); + // set-up a finder to find the listener + $finder = new Finder(); + $finder->files()->name('PatternLabListener.php')->in($pathPackage); - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); - - // go through the package items - foreach($objects as $name => $object) { + // iterate over the returned objects + foreach ($finder as $file) { - if ($object->getFilename() == "PatternLabListener.php") { - - // create the name - $dirs = explode("/",$object->getPath()); - $listenerName = "\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$object->getFilename()); - - // check to see what we should do with the listener info - if (!$remove && !in_array($listenerName,$listenerList["listeners"])) { - $listenerList["listeners"][] = $listenerName; - } else if ($remove && in_array($listenerName,$listenerList["listeners"])) { - $key = array_search($listenerName, $listenerList["listeners"]); - unset($listenerList["listeners"][$key]); - } - - // write out the listener list - file_put_contents($pathList,json_encode($listenerList)); - - break; - + // create the name + $dirs = explode("/",$file->getPath()); + $listenerName = "\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); + + // check to see what we should do with the listener info + if (!$remove && !in_array($listenerName,$listenerList["listeners"])) { + $listenerList["listeners"][] = $listenerName; + } else if ($remove && in_array($listenerName,$listenerList["listeners"])) { + $key = array_search($listenerName, $listenerList["listeners"]); + unset($listenerList["listeners"][$key]); } + // write out the listener list + file_put_contents($pathList,json_encode($listenerList)); + } } @@ -383,36 +521,28 @@ protected static function scanForPatternEngineRule($pathPackage,$remove = false) // load pattern engine list $patternEngineList = json_decode(file_get_contents($pathList),true); - // grab the list of files in the package - $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pathPackage), \RecursiveIteratorIterator::CHILD_FIRST); + // set-up a finder to find the pattern engine + $finder = new Finder(); + $finder->files()->name("PatternEngineRule.php")->in($pathPackage); - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); - - // go through the package items - foreach ($objects as $name => $object) { + // iterate over the returned objects + foreach ($finder as $file) { - if ($object->getFilename() == "PatternEngineRule.php") { - - // create the name - $dirs = explode("/",$object->getPath()); - $patternEngineName = "\\".$dirs[count($dirs)-3]."\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$object->getFilename()); - - // check what we should do with the pattern engine info - if (!$remove && !in_array($patternEngineName, $patternEngineList["patternengines"])) { - $patternEngineList["patternengines"][] = $patternEngineName; - } else if ($remove && in_array($patternEngineName, $patternEngineList["patternengines"])) { - $key = array_search($patternEngineName, $patternEngineList["patternengines"]); - unset($patternEngineList["patternengines"][$key]); - } - - // write out the pattern engine list - file_put_contents($pathList,json_encode($patternEngineList)); - - break; - + /// create the name + $dirs = explode("/",$file->getPath()); + $patternEngineName = "\\".$dirs[count($dirs)-3]."\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); + + // check what we should do with the pattern engine info + if (!$remove && !in_array($patternEngineName, $patternEngineList["patternengines"])) { + $patternEngineList["patternengines"][] = $patternEngineName; + } else if ($remove && in_array($patternEngineName, $patternEngineList["patternengines"])) { + $key = array_search($patternEngineName, $patternEngineList["patternengines"]); + unset($patternEngineList["patternengines"][$key]); } + // write out the pattern engine list + file_put_contents($pathList,json_encode($patternEngineList)); + } } From 8df152ee485cfa348c98fa7ec3a04cb8041edc51 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 11:40:31 -0500 Subject: [PATCH 048/436] minor style change --- src/PatternLab/FileUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index 1b319740..0eb1c479 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -160,7 +160,7 @@ public static function cleanPublic() { $objects->setFlags(\FilesystemIterator::SKIP_DOTS); // for each file figure out what to do with it - foreach($objects as $name => $object) { + foreach ($objects as $name => $object) { if ($object->isDir()) { // if this is a directory remove it From e42f1c812537e0d54993eb3830c08ec33cbb8d66 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 11:41:28 -0500 Subject: [PATCH 049/436] adding note about why not using symfony finder --- src/PatternLab/FileUtil.php | 2 ++ src/PatternLab/PatternData.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index 0eb1c479..07648d2d 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -154,6 +154,7 @@ public static function cleanPublic() { // make sure patterns exists before trying to clean it if (is_dir($patternPublicDir)) { + // symfony finder doesn't support child first and I don't want to do array crap $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($patternPublicDir), \RecursiveIteratorIterator::CHILD_FIRST); // make sure dots are skipped @@ -203,6 +204,7 @@ public static function cleanPublic() { // for the remaining dirs in public delete them and their files foreach ($publicDirs as $dir) { + // symfony finder doesn't support child first and I don't want to do array crap $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::CHILD_FIRST); // make sure dots are skipped diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 2a8d001d..5175d4b4 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -104,6 +104,7 @@ public static function gather($options = array()) { $dispatcherInstance->dispatch("patternData.rulesLoaded",$event); // iterate over the patterns & related data and regenerate the entire site if they've changed + // seems a little silly to use symfony finder here. not really giving me any power $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(Config::getOption("patternSourceDir")), \RecursiveIteratorIterator::SELF_FIRST); $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS); From 7a658e855f344924dcab27fa3ed6df067123c000 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 14:35:56 -0500 Subject: [PATCH 050/436] a server command because i don't want to muck with apache --- .../Console/Commands/ServerCommand.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/PatternLab/Console/Commands/ServerCommand.php diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php new file mode 100644 index 00000000..c60183d4 --- /dev/null +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -0,0 +1,41 @@ +command = "server"; + + Console::setCommand($this->command,"Start the PHP-based server","The server command will start PHP's web server for you.","s"); + + } + + public function run() { + + // set-up defaults + $publicDir = Config::getOption("publicDir"); + $coreDir = Config::getOption("coreDir"); + + Console::writeInfo("server started on localhost:8080. use ctrl+c to exit..."); + passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S localhost:8080 ".$coreDir."/server/router.php"); + + } + +} From 9c328c89233b90392aeef41463f38c118ae47d63 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 29 Dec 2014 15:12:30 -0500 Subject: [PATCH 051/436] making a structure for controls to hide that won't blow up hogan --- src/PatternLab/Builder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 6c403102..7fdad330 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -136,8 +136,13 @@ protected function generateIndex() { $output .= "var config = ".json_encode($config).";"; // load the ish Controls + $ishControlsHide = Config::getOption("ishControlsHide"); + $controlsToHide = array(); + foreach ($ishControlsHide as $controlToHide) { + $controlsToHide[$controlToHide] = "true"; + } $ishControls = array(); - $ishControls["ishControlsHide"] = Config::getOption("ishControlsHide"); + $ishControls["ishControlsHide"] = $controlsToHide; $ishControls["mqs"] = $this->gatherMQs(); $output .= "var ishControls = ".json_encode($ishControls).";"; From 1330f366e2d77483b806418b5f615be5d5fd6544 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 09:50:04 -0500 Subject: [PATCH 052/436] removing a use for an unused class --- src/PatternLab/PatternData.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 5175d4b4..3fed6091 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -18,7 +18,6 @@ use \PatternLab\PatternData\Exporters\DataLinkExporter; use \PatternLab\PatternData\Exporters\DataMergeExporter; use \PatternLab\PatternData\Exporters\NavItemsExporter; -use \PatternLab\PatternData\Exporters\PatternPartialsExporter; use \PatternLab\PatternData\Exporters\PatternPathSrcExporter; use \PatternLab\PatternData\Exporters\ViewAllPathsExporter; use \PatternLab\PatternData\Helpers\LineageHelper; From 6d7aa349b4e5b8f4b25450cedcd6141282f9ee52 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 09:50:22 -0500 Subject: [PATCH 053/436] updating the code comment --- src/PatternLab/PatternData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 3fed6091..b8b73c83 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -185,7 +185,7 @@ public static function get() { } /** - * Return the overall store of PatternData + * Return the directory separator */ public static function getDirSep() { return self::$dirSep; From 8a98c1a3fa496fdf832641d37f7e1d05b5ad1219 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 09:50:40 -0500 Subject: [PATCH 054/436] adding support for a front meta check --- src/PatternLab/PatternData.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index b8b73c83..fcfe0dbf 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -37,6 +37,7 @@ class PatternData { protected static $patternTypeDash = ""; protected static $rules = array(); protected static $dirSep = DIRECTORY_SEPARATOR; + protected static $frontMeta = array("-","_"); /** * Return if a specific option is set @@ -191,6 +192,13 @@ public static function getDirSep() { return self::$dirSep; } + /** + * Return the front meta bits (hidden and noviewall) + */ + public static function getFrontMeta() { + return self::$frontMeta; + } + /** * Return a specific item from the store * @param {String} the option to check From f4230516c1a2dd6bb3a876e3b4ad75b8b4f9aa89 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 09:51:34 -0500 Subject: [PATCH 055/436] adding support for removing a pattern from "view all" views --- .../Exporters/PatternPartialsExporter.php | 2 +- .../PatternData/Rules/PatternRule.php | 15 ++++++----- .../PatternData/Rules/PseudoPatternRule.php | 26 +++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 9934bc7b..407eefe9 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -42,7 +42,7 @@ public function run($type = "", $subtype = "") { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && (!$patternStoreData["hidden"]) && ($patternStoreData["depth"] == 2) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { + if (($patternStoreData["category"] == "pattern") && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] == 2) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index ae8363b5..eab3a4b0 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -41,10 +41,15 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternTypeClean = PatternData::getPatternTypeClean(); $patternTypeDash = PatternData::getPatternTypeDash(); $dirSep = PatternData::getDirSep(); + $frontMeta = PatternData::getFrontMeta(); + + // should this pattern get rendered? + $hidden = ($name[0] == "_"); + $noviewall = ($name[0] == "-"); // set-up the names - $patternFull = $name; // 00-colors.mustache - $pattern = str_replace(".".$this->extProp,"",$patternFull); // 00-colors + $patternFull = in_array($name[0],$frontMeta) ? substr($name,1) : $name; // 00-colors.mustache + $pattern = str_replace(".".$this->extProp,"",$patternFull); // 00-colors $patternState = ""; // check for pattern state @@ -55,15 +60,12 @@ public function run($depth, $ext, $path, $pathName, $name) { } // finish setting up vars - $patternDash = $this->getPatternName(str_replace("_","",$pattern),false); // colors + $patternDash = $this->getPatternName($pattern,false); // colors $patternClean = str_replace("-"," ",$patternDash); // colors (dashes replaced with spaces) $patternPartial = $patternTypeDash."-".$patternDash; // atoms-colors $patternPath = str_replace(".".$this->extProp,"",$pathName); // 00-atoms/01-global/00-colors $patternPathDash = str_replace($dirSep,"-",$patternPath); // 00-atoms-01-global-00-colors (file path) - // should this pattern get rendered? - $hidden = ($patternFull[0] == "_"); - // create a key for the data store $patternStoreKey = $patternPartial; @@ -78,6 +80,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "breadcrumb" => $patternTypeClean, "state" => $patternState, "hidden" => $hidden, + "noviewall" => $noviewall, "depth" => $depth, "ext" => $ext, "path" => $path, diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 16290fba..22260201 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -42,9 +42,14 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternType = PatternData::getPatternType(); $patternTypeDash = PatternData::getPatternTypeDash(); $dirSep = PatternData::getDirSep(); + $frontMeta = PatternData::getFrontMeta(); + + // should this pattern get rendered? + $hidden = ($name[0] == "_"); + $noviewall = ($name[0] == "-"); // set-up the names - $patternFull = $name; // 00-colors.mustache + $patternFull = in_array($name[0],$frontMeta) ? substr($name,1) : $name; // 00-colors~foo.mustache $patternState = ""; // check for pattern state @@ -69,15 +74,18 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternPartial = $patternTypeDash."-".$patternDash; // pages-homepage-emergency $patternPath = str_replace(".".$ext,"",str_replace("~","-",$pathName)); // 00-atoms/01-global/00-colors $patternPathDash = str_replace($dirSep,"-",$patternPath); // 00-atoms-01-global-00-colors (file path) - $patternPathOrigBits = explode("~",$pathName); - $patternPathOrig = $patternPathOrigBits[0]; // 04-pages/00-homepage - $patternPathOrigDash = str_replace($dirSep,"-",$patternPathOrig); // 04-pages-00-homepage - // should this pattern get rendered? - $hidden = ($patternFull[0] == "_"); + // check the original pattern path. if it doesn't exist make a guess + $patternPathOrig = PatternData::getPatternOption($patternBaseOrig,"pathName"); // 04-pages/00-homepage + $patternPathOrigDash = PatternData::getPatternOption($patternBaseOrig,"pathDash"); // 04-pages-00-homepage + if (!$patternPathOrig) { + $patternPathOrigBits = explode("~",$pathName); + $patternPathOrig = $patternPathOrigBits[0]; // 04-pages/00-homepage + $patternPathOrigDash = str_replace($dirSep,"-",$patternPathOrig); // 04-pages-00-homepage + } // create a key for the data store - $patternStoreKey = $patternPartial; + $patternStoreKey = $patternPartial; // collect the data $patternStoreData = array("category" => "pattern", @@ -90,6 +98,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "breadcrumb" => $patternType, "state" => $patternState, "hidden" => $hidden, + "noviewall" => $noviewall, "depth" => $depth, "ext" => $ext, "path" => $path, @@ -156,7 +165,8 @@ public function run($depth, $ext, $path, $pathName, $name) { } - $patternStoreData["data"] = array_replace_recursive($patternDataBase, $patternData); + // make sure the pattern data is an array before merging the data + $patternStoreData["data"] = is_array($patternData) ? array_replace_recursive($patternDataBase, $patternData) : $patternDataBase; // if the pattern data store already exists make sure it is merged and overwrites this data $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; From 1d9873cf1fd1e2abb4ce60fa7b8c8205d7e67c8a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 09:52:13 -0500 Subject: [PATCH 056/436] handling mis-typed arrays --- src/PatternLab/PatternData/Helpers/LineageHelper.php | 2 +- src/PatternLab/PatternData/Helpers/PatternStateHelper.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 86832c39..c66fdd38 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -99,7 +99,7 @@ public function run() { $storeTake2 = PatternData::get(); foreach ($storeTake2 as $haystackKey => $haystackData) { - if (($haystackData["category"] == "pattern") && (isset($haystackData["lineages"]))) { + if (($haystackData["category"] == "pattern") && (isset($haystackData["lineages"])) && (!empty($haystackData["lineages"]))) { foreach ($haystackData["lineages"] as $haystackLineage) { diff --git a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php index 38fe46a6..8316a1b2 100644 --- a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php @@ -91,7 +91,7 @@ public function run() { if ($patternStoreData["category"] == "pattern") { - if (isset($patternStoreData["lineages"])) { + if (isset($patternStoreData["lineages"]) && !empty($patternStoreData["lineages"])) { foreach ($patternStoreData["lineages"] as $patternLineageKey => $patternLineageInfo) { @@ -105,7 +105,7 @@ public function run() { } - if (isset($patternStoreData["lineagesR"])) { + if (isset($patternStoreData["lineagesR"]) && !empty($patternStoreData["lineagesR"])) { foreach ($patternStoreData["lineagesR"] as $patternLineageKey => $patternLineageInfo) { From 34e3a8528165f2ac3f35a9f714f7ab1caa245777 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 10:20:23 -0500 Subject: [PATCH 057/436] unused function? --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 53a30016..9e9957d2 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -30,6 +30,7 @@ class Config { /** * Clean a given dir from the config file + * NO IDEA WHAT THIS IS USED FOR * @param {String} directory to be cleaned * * @return {String} cleaned directory From 6c2a9dd43476af8d79a00d7c1e79f9ffdfd18f0d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 10:39:15 -0500 Subject: [PATCH 058/436] renaming Config::get() to Config::getOptions() --- src/PatternLab/Config.php | 18 +++++++++--------- .../Console/Commands/ConfigCommand.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 9e9957d2..f549e484 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -45,15 +45,6 @@ protected static function cleanDir($dir) { } - /** - * Get the options set in the config - * - * @return {Array} the options from the config - */ - public static function get() { - return self::$options; - } - /** * Get the value associated with an option from the Config * @param {String} the name of the option to be checked @@ -74,6 +65,15 @@ public static function getOption($optionName = "") { } + /** + * Get the options set in the config + * + * @return {Array} the options from the config + */ + public static function getOptions() { + return self::$options; + } + /** * Adds the config options to a var to be accessed from the rest of the system * If it's an old config or no config exists this will update and generate it. diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 706115ab..2df58b90 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -36,7 +36,7 @@ public function run() { if (Console::findCommandOption("list")) { // get all of the options - $options = Config::get(); + $options = Config::getOptions(); // sort 'em alphabetically ksort($options); From 76cbc426c8c30b781835b5658a16c1bc63fc4fda Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 10:53:02 -0500 Subject: [PATCH 059/436] smarter set-up of baseDir --- src/PatternLab/Config.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index f549e484..6b57f868 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -88,14 +88,21 @@ public static function init($baseDir = "", $verbose = true) { // normalize the baseDir $baseDir = FileUtil::normalizePath($baseDir); - self::$options["baseDir"] = $baseDir; + + // double-check the default config file exists + if (!is_dir($baseDir)) { + Console::writeError("make sure ".$baseDir." exists..."); + } + + // set the baseDir option + self::$options["baseDir"] = ($baseDir[strlen($baseDir)-1] == DIRECTORY_SEPARATOR) ? $baseDir : $baseDir.DIRECTORY_SEPARATOR; // can't add __DIR__ above so adding here if (!self::$dirAdded) { // set-up the paths - self::$userConfigDirClean = $baseDir.DIRECTORY_SEPARATOR.self::$userConfigDirClean; - self::$userConfigDirDash = $baseDir.DIRECTORY_SEPARATOR.self::$userConfigDirDash; + self::$userConfigDirClean = self::$options["baseDir"].self::$userConfigDirClean; + self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; self::$plConfigPath = __DIR__.DIRECTORY_SEPARATOR.self::$plConfigPath; @@ -163,14 +170,12 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs - $baseFull = $baseDir.DIRECTORY_SEPARATOR; - self::$options["baseDir"] = $baseDir; - self::$options["coreDir"] = (is_dir($baseFull."_core")) ? $baseFull."_core" : $baseFull."core"; - self::$options["exportDir"] = isset(self::$options["exportDir"]) ? $baseFull.self::cleanDir(self::$options["exportDir"]) : $baseFull."exports"; - self::$options["packagesDir"] = isset(self::$options["packagesDir"]) ? $baseFull.self::cleanDir(self::$options["packagesDir"]) : $baseFull."packages"; - self::$options["publicDir"] = isset(self::$options["publicDir"]) ? $baseFull.self::cleanDir(self::$options["publicDir"]) : $baseFull."public"; - self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? $baseFull.self::cleanDir(self::$options["scriptsDir"]) : $baseFull."scripts"; - self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? $baseFull.self::cleanDir(self::$options["sourceDir"]) : $baseFull."source"; + self::$options["coreDir"] = (is_dir($baseFull."_core")) ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; + self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; + self::$options["packagesDir"] = isset(self::$options["packagesDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["packagesDir"]) : self::$options["baseDir"]."packages"; + self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; + self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts"; + self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source"; self::$options["componentDir"] = self::$options["publicDir"]."/patternlab-components"; self::$options["dataDir"] = self::$options["sourceDir"]."/_data"; self::$options["patternExportDir"] = self::$options["exportDir"]."/patterns"; From a97c81ed98f091406364c00ea8254f1cc83fa68a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 10:54:25 -0500 Subject: [PATCH 060/436] smarter path error --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 6b57f868..d495a9d6 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -121,7 +121,7 @@ public static function init($baseDir = "", $verbose = true) { // double-check the default config file exists if (!file_exists(self::$plConfigPath)) { - Console::writeError("make sure config.ini.default exists before trying to have Pattern Lab build the config.ini file automagically..."); + Console::writeError("make sure ".self::$plConfigPath." exists before trying to have Pattern Lab build the config.ini file automagically..."); } // set the default config using the pattern lab config From 218e4072d6dd7e0cf3096dd250fd43e0fb408d88 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 11:37:34 -0500 Subject: [PATCH 061/436] switching to a yaml based config --- config/config.ini.default | 33 -------------------------------- config/config.yml.default | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 33 deletions(-) delete mode 100644 config/config.ini.default create mode 100644 config/config.yml.default diff --git a/config/config.ini.default b/config/config.ini.default deleted file mode 100644 index 49626723..00000000 --- a/config/config.ini.default +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Configuration Options for Pattern Lab - * If config.ini doesn't exist Pattern Lab will try to create a new version - */ - -v = "0.7.12" - -// what to do when included config var conflicts, q for question, a for always override, n for never override -overrideConfig = "q" - -// file extensions to ignore when building or watching the source dir, separate with a comma -ie = "scss,DS_Store,less" - -// directories and files to ignore when building or watching the source dir, separate with a comma -id = "scss,.svn,.sass-cache" - -// whether the public directory should be cleaned when generating your site -cleanPublic = "true" - -// the order of pattern states, css class names -patternStates = "inprogress,inreview,complete" - -// the pattern types that shouldn't be included in the style guide, useful if you nest pages/templates -styleGuideExcludes = "" - -// should the cache buster be on, set to false to set the cacheBuster value to 0 -cacheBusterOn = "true" - -// project directories -exportDir = "export" -packagesDir = "packages" -publicDir = "public" -sourceDir = "source" diff --git a/config/config.yml.default b/config/config.yml.default new file mode 100644 index 00000000..9e3122ca --- /dev/null +++ b/config/config.yml.default @@ -0,0 +1,40 @@ +## Configuration Options for Pattern Lab + +# pattern lab version +v: "0.7.12" + +# what to do when included config var conflicts, q for question, a for always override, n for never override +overrideConfig: "q" + +# file extensions to ignore when building or watching the source dir, separate with a comma +ie: + - "DS_Store" + - "less" + - "scss" + +# directories and files to ignore when building or watching the source dir, separate with a comma +id: + - "scss" + - ".svn" + - ".sass-cache" + +# whether the public directory should be cleaned when generating your site +cleanPublic: "true" + +# the order of pattern states, css class names +patternStates: + - "inprogress" + - "inreview" + - "complete" + +# the pattern types that shouldn't be included in the style guide, useful if you nest pages/templates +styleGuideExcludes: "" + +# should the cache buster be on, set to false to set the cacheBuster value to 0 +cacheBusterOn: "true" + +# project directories +exportDir: "export" +packagesDir: "packages" +publicDir: "public" +sourceDir: "source" From 4f70a61feabbf616401f3bd1063c43b100bb0f82 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 12:07:31 -0500 Subject: [PATCH 062/436] better error message when there's a missing pattern extension --- src/PatternLab/PatternEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternEngine.php b/src/PatternLab/PatternEngine.php index b08b9a6e..ce8fda1a 100644 --- a/src/PatternLab/PatternEngine.php +++ b/src/PatternLab/PatternEngine.php @@ -45,7 +45,7 @@ public static function init() { } if (!$found) { - Console::writeError("the supplied pattern extension didn't match a pattern loader rule..."); + Console::writeError("the supplied pattern extension didn't match a pattern loader rule. check your config..."); } } From 7c110961b4eb3c063a940cdea7286afcf8e8d80f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 12:07:55 -0500 Subject: [PATCH 063/436] switching to YAML as the base config format --- src/PatternLab/Config.php | 84 ++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index d495a9d6..27768d5d 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -15,17 +15,18 @@ use \PatternLab\Console; use \PatternLab\FileUtil; use \PatternLab\Timer; +use \Symfony\Component\Yaml\Yaml; +use \Symfony\Component\Yaml\Exception\ParseException; class Config { protected static $options = array(); - protected static $userConfig = "config.ini"; + protected static $userConfig = "config.yml"; protected static $userConfigDir = ""; protected static $userConfigDirClean = "config"; protected static $userConfigDirDash = "_config"; protected static $userConfigPath = ""; - protected static $plConfigPath = "../../config/config.ini.default"; - protected static $cleanValues = array("ie","id","patternStates","styleGuideExcludes","ishControlsHide"); + protected static $plConfigPath = "../../config/config.yml.default"; protected static $dirAdded = false; /** @@ -125,10 +126,15 @@ public static function init($baseDir = "", $verbose = true) { } // set the default config using the pattern lab config - if (!self::$options = @parse_ini_file(self::$plConfigPath)) { - Console::writeError("Config parse error in ".self::$plConfigPath."..."); + try { + $data = Yaml::parse(file_get_contents(self::$plConfigPath)); + } catch (ParseException $e) { + Console::writeError("Config parse error in ".self::$plConfigPath.": ".$e->getMessage()); } + // load the options from the default file + self::loadOptions($data); + // make sure these are copied $defaultOptions = self::$options; @@ -140,9 +146,12 @@ public static function init($baseDir = "", $verbose = true) { if (!file_exists(self::$userConfigPath)) { $migrate = true; } else { - if (!self::$options = @parse_ini_file(self::$userConfigPath)) { - Console::writeError("Config parse error in ".self::$userConfigPath."..."); + try { + $data = Yaml::parse(file_get_contents(self::$userConfigPath)); + } catch (ParseException $e) { + Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); } + self::loadOptions($data); } // compare version numbers @@ -170,7 +179,7 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs - self::$options["coreDir"] = (is_dir($baseFull."_core")) ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; + self::$options["coreDir"] = (is_dir(self::$options["baseDir"]."_core")) ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; self::$options["packagesDir"] = isset(self::$options["packagesDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["packagesDir"]) : self::$options["baseDir"]."packages"; self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; @@ -182,16 +191,9 @@ public static function init($baseDir = "", $verbose = true) { self::$options["patternPublicDir"] = self::$options["publicDir"]."/patterns"; self::$options["patternSourceDir"] = self::$options["sourceDir"]."/_patterns"; - // populate some standard variables out of the config - foreach (self::$options as $key => $value) { - - // if the variables are array-like make sure the properties are validated/trimmed/lowercased before saving - if (in_array($key,self::$cleanValues)) { - $values = explode(",",$value); - array_walk($values,'PatternLab\Util::trim'); - self::$options[$key] = $values; - } - + // make sure styleguideExcludes is set to an array even if it's empty + if (is_string(self::$options["styleGuideExcludes"])) { + self::$options["styleGuideExcludes"] = array(); } // set the cacheBuster @@ -209,6 +211,39 @@ public static function init($baseDir = "", $verbose = true) { } + /** + * Check to see if the given array is an associative array + * @param {Array} the array to be checked + * + * @return {Boolean} whether it's an associative array + */ + protected static function isAssoc($array) { + return (bool) count(array_filter(array_keys($array), 'is_string')); + } + + /** + * Load the options into self::$options + * @param {Array} the data to be added + * @param {String} any addition that may need to be added to the option key + */ + public static function loadOptions($data,$parentKey = "") { + + foreach ($data as $key => $value) { + + $key = $parentKey.trim($key); + + if (is_array($value) && self::isAssoc($value)) { + self::loadOptions($value,$key."."); + } else if (is_array($value) && !self::isAssoc($value)) { + self::$options[$key] = $value; + } else { + self::$options[$key] = trim($value); + } + + } + + } + /** * Add an option and associated value to the base Config * @param {String} the name of the option to be added @@ -319,13 +354,16 @@ public static function updateOption($optionName = "", $optionValue = "") { */ protected static function writeUpdateConfigOption($optionName,$optionValue) { - $configOutput = ""; - $options = parse_ini_file(self::$userConfigPath); + // parse the YAML options + try { + $options = Yaml::parse(file_get_contents(self::$userConfigPath)); + } catch (ParseException $e) { + Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); + } $options[$optionName] = $optionValue; - foreach ($options as $key => $value) { - $configOutput .= $key." = \"".$value."\"\n"; - } + // dump the YAML + $configOutput = Yaml::dump($array, 3); // write out the new config file file_put_contents(self::$userConfigPath,$configOutput); From 4b6028c18a0da5089cfeb8c875a072583da3d6dd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 12:09:12 -0500 Subject: [PATCH 064/436] missed a file output --- src/PatternLab/Config.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 27768d5d..cd59e37c 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -386,11 +386,8 @@ protected static function writeNewConfigFile($oldOptions,$defaultOptions) { } } - // create the output data - $configOutput = ""; - foreach ($defaultOptions as $key => $value) { - $configOutput .= $key." = \"".$value."\"\n"; - } + // dump the YAML + $configOutput = Yaml::dump($defaultOptions, 3); // write out the new config file file_put_contents(self::$userConfigPath,$configOutput); From 4f7e0b01c8b8a107d1fcb48184b219661bc41ded Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 12:09:21 -0500 Subject: [PATCH 065/436] using the correct array for the dump --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index cd59e37c..b3fe396f 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -363,7 +363,7 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { $options[$optionName] = $optionValue; // dump the YAML - $configOutput = Yaml::dump($array, 3); + $configOutput = Yaml::dump($options, 3); // write out the new config file file_put_contents(self::$userConfigPath,$configOutput); From 10156995f0e8abdf7d43a128a8a72d54f0bba10b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 12:21:17 -0500 Subject: [PATCH 066/436] now know what this is for. used in self::init() --- src/PatternLab/Config.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index b3fe396f..afbfa13d 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -31,7 +31,6 @@ class Config { /** * Clean a given dir from the config file - * NO IDEA WHAT THIS IS USED FOR * @param {String} directory to be cleaned * * @return {String} cleaned directory From 42da2b7d60a8b5d0b0bab6a7634f3008239c34ab Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 15:06:45 -0500 Subject: [PATCH 067/436] properly setting the error to reflect yaml file --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index afbfa13d..55fc0f44 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -121,7 +121,7 @@ public static function init($baseDir = "", $verbose = true) { // double-check the default config file exists if (!file_exists(self::$plConfigPath)) { - Console::writeError("make sure ".self::$plConfigPath." exists before trying to have Pattern Lab build the config.ini file automagically..."); + Console::writeError("make sure ".self::$plConfigPath." exists before trying to have Pattern Lab build the config.yml file automagically..."); } // set the default config using the pattern lab config From 569c174aedc86f8fcb9d9b8ab9c87568656a06ec Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 15:07:06 -0500 Subject: [PATCH 068/436] fixing missing semi-colons >.< --- src/PatternLab/InstallerUtil.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 7d5b65ee..665e8c4c 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -157,7 +157,7 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat if (isset($componentTypes["css"])) { $fileList = self::buildFileList($componentTypes["css"]); - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); self::updateComponentJSON("css",$componentTypes["css"]); } @@ -174,7 +174,7 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat $javascriptList = $componentList["javascript"]; } - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); self::updateComponentJSON("javascript",$javascriptList); } @@ -183,7 +183,7 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat if (isset($componentTypes["images"])) { $fileList = self::buildFileList($componentTypes["images"]); - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); } @@ -191,7 +191,7 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat if (isset($componentList["templates"])) { $fileList = self::buildFileList($componentTypes["templates"]); - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList) + self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); self::updateComponentJSON("templates",$componentTypes["templates"]); } From 0761ca93f30aceee81ddb4f3a92c98dd3ffcf22f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 30 Dec 2014 15:27:34 -0500 Subject: [PATCH 069/436] better path messaging & spacing --- src/PatternLab/InstallerUtil.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 665e8c4c..c4d26deb 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -238,6 +238,9 @@ protected static function pathExists($packageName,$path) { if (self::$fs->exists($path)) { + // set-up a human readable prompt + $humanReadablePath = str_replace(Config::getOption("baseDir"), "./", $path); + // set if the prompt should fire $prompt = true; @@ -263,15 +266,15 @@ protected static function pathExists($packageName,$path) { if ($prompt) { // prompt for input using the supplied query - $prompt = "the path ".$path." already exists. overwrite it with the contents of ".$packageName."?"; + $prompt = "the path ".$humanReadablePath." already exists. overwrite it with the contents from the ".$packageName." package?"; $options = "Y/n"; $input = Console::promptInput($prompt,$options); if ($input == "y") { - Console::writeTag("ok","contents of ".$path." being overwritten...", false, false); + Console::writeTag("ok","contents of ".$humanReadablePath." being overwritten...", false, true); return false; } else { - Console::writeWarning("contents of ".$path." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, false); + Console::writeWarning("contents of ".$humanReadablePath." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, true); return true; } From 7d2669540651e8f8e63f49374fb62fb2a5b3d498 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 31 Dec 2014 11:39:09 -0500 Subject: [PATCH 070/436] adding a new line to end --- src/PatternLab/Annotations.php | 2 +- src/PatternLab/Console/Event.php | 2 +- src/PatternLab/Data.php | 2 +- src/PatternLab/Fetch.php | 2 +- src/PatternLab/Generator.php | 2 +- src/PatternLab/JSON.php | 2 +- src/PatternLab/Parsers/Documentation.php | 2 +- src/PatternLab/PatternData.php | 2 +- src/PatternLab/PatternData/Event.php | 2 +- src/PatternLab/PatternData/Exporters/NavItemsExporter.php | 2 +- src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php | 2 +- src/PatternLab/PatternData/Helpers/LineageHelper.php | 2 +- src/PatternLab/PatternData/Rule.php | 2 +- src/PatternLab/PatternData/Rules/DocumentationRule.php | 2 +- src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php | 1 - src/PatternLab/PatternData/Rules/PatternInfoRule.php | 1 - src/PatternLab/PatternData/Rules/PatternRule.php | 2 +- src/PatternLab/PatternData/Rules/PatternSubtypeRule.php | 2 +- src/PatternLab/PatternData/Rules/PatternTypeRule.php | 2 +- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 1 - src/PatternLab/Template.php | 2 +- src/PatternLab/Timer.php | 2 +- 22 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index d5bb4a82..330a5607 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -106,4 +106,4 @@ public static function get() { return self::$store; } -} \ No newline at end of file +} diff --git a/src/PatternLab/Console/Event.php b/src/PatternLab/Console/Event.php index a8bb9e22..aed960a0 100644 --- a/src/PatternLab/Console/Event.php +++ b/src/PatternLab/Console/Event.php @@ -26,4 +26,4 @@ public function getOptions() { return $this->options; } -} \ No newline at end of file +} diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 18d49a65..807a86b4 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -354,4 +354,4 @@ public static function setPatternListItems($optionName,$optionValue) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 58afe302..80513303 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -35,4 +35,4 @@ public function fetch($package = "") { } -} \ No newline at end of file +} diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index afc63df0..34b75f3e 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -197,4 +197,4 @@ public function printSaying() { } -} \ No newline at end of file +} diff --git a/src/PatternLab/JSON.php b/src/PatternLab/JSON.php index 95acb512..55de4c0e 100644 --- a/src/PatternLab/JSON.php +++ b/src/PatternLab/JSON.php @@ -51,4 +51,4 @@ public static function lastErrorMsg($file,$message,$data) { } } -} \ No newline at end of file +} diff --git a/src/PatternLab/Parsers/Documentation.php b/src/PatternLab/Parsers/Documentation.php index eb0def1c..f2860621 100644 --- a/src/PatternLab/Parsers/Documentation.php +++ b/src/PatternLab/Parsers/Documentation.php @@ -136,4 +136,4 @@ protected static function setLineEndings() { } } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index fcfe0dbf..876a121c 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -486,4 +486,4 @@ public static function setPatternTypeDash($optionValue) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Event.php b/src/PatternLab/PatternData/Event.php index b320b206..c68cdef8 100644 --- a/src/PatternLab/PatternData/Event.php +++ b/src/PatternLab/PatternData/Event.php @@ -27,4 +27,4 @@ public function getOptions() { return $this->options; } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php index 2da727b4..4b744bd0 100644 --- a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php +++ b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php @@ -158,4 +158,4 @@ public function run() { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php b/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php index ab3cf427..9c68185e 100644 --- a/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php +++ b/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php @@ -72,4 +72,4 @@ public function run($navItems) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index c66fdd38..e81fb736 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -172,4 +172,4 @@ protected function findLineages($filename) { return array(); } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Rule.php b/src/PatternLab/PatternData/Rule.php index 7d51ce1b..0b2c0cc5 100644 --- a/src/PatternLab/PatternData/Rule.php +++ b/src/PatternLab/PatternData/Rule.php @@ -107,4 +107,4 @@ protected function getPatternName($pattern, $clean = true) { return ($clean) ? (str_replace("-"," ",$patternName)) : $patternName; } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index 3c2f77ff..9eb5a23d 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -96,4 +96,4 @@ public function run($depth, $ext, $path, $pathName, $name) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php index 2023e252..29eb5031 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php @@ -67,4 +67,3 @@ public function run($depth, $ext, $path, $pathName, $name) { } } - diff --git a/src/PatternLab/PatternData/Rules/PatternInfoRule.php b/src/PatternLab/PatternData/Rules/PatternInfoRule.php index 015b84b2..98fd0ff4 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoRule.php @@ -88,4 +88,3 @@ public function run($depth, $ext, $path, $pathName, $name) { } } - diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index eab3a4b0..68cc025c 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -105,4 +105,4 @@ public function run($depth, $ext, $path, $pathName, $name) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php b/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php index 3f486199..395d1bae 100644 --- a/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php +++ b/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php @@ -76,4 +76,4 @@ public function run($depth, $ext, $path, $pathName, $name) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Rules/PatternTypeRule.php b/src/PatternLab/PatternData/Rules/PatternTypeRule.php index e36d19a7..3ce60e1e 100644 --- a/src/PatternLab/PatternData/Rules/PatternTypeRule.php +++ b/src/PatternLab/PatternData/Rules/PatternTypeRule.php @@ -68,4 +68,4 @@ public function run($depth, $ext, $path, $pathName, $name) { } -} \ No newline at end of file +} diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 22260201..adee85f9 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -175,4 +175,3 @@ public function run($depth, $ext, $path, $pathName, $name) { } } - diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index cd0a072f..6c17e373 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -129,4 +129,4 @@ public static function setPatternLoader($instance) { self::$patternLoader = $instance; } -} \ No newline at end of file +} diff --git a/src/PatternLab/Timer.php b/src/PatternLab/Timer.php index 068504aa..d7dd4d57 100644 --- a/src/PatternLab/Timer.php +++ b/src/PatternLab/Timer.php @@ -113,4 +113,4 @@ public static function stop() { } -} \ No newline at end of file +} From 82e0c71bc913a4d80b482ff70ec0784e2b46170e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 31 Dec 2014 12:43:38 -0500 Subject: [PATCH 071/436] standardizing on UTF-8 for htmlentities() --- src/PatternLab/Builder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 7fdad330..7b94aef0 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -212,9 +212,9 @@ protected function generatePatterns($options = array()) { // modify the pattern mark-up $markup = $patternStoreData["code"]; - $markupEncoded = htmlentities($markup); + $markupEncoded = htmlentities($markup,ENT_COMPAT,"UTF-8"); $markupFull = $patternStoreData["header"].$markup.$patternStoreData["footer"]; - $markupEngine = htmlentities(file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension)); + $markupEngine = htmlentities(file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension),ENT_COMPAT,"UTF-8"); // if the pattern directory doesn't exist create it if (!is_dir($patternPublicDir."/".$path)) { From e4e903d6d18a4775aa6f058d83afd29a6e9e7891 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 31 Dec 2014 12:47:17 -0500 Subject: [PATCH 072/436] code style fix --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 55fc0f44..44b08dfb 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -178,7 +178,7 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs - self::$options["coreDir"] = (is_dir(self::$options["baseDir"]."_core")) ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; + self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; self::$options["packagesDir"] = isset(self::$options["packagesDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["packagesDir"]) : self::$options["baseDir"]."packages"; self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; From 7dd11e29fc5928f84b4c66351e2213d83efc4300 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 31 Dec 2014 12:51:53 -0500 Subject: [PATCH 073/436] standardizing setting the "hidden" flag --- .../PatternData/Rules/DocumentationRule.php | 11 +++++------ .../PatternData/Rules/PatternInfoListItemsRule.php | 13 ++++++------- .../PatternData/Rules/PatternInfoRule.php | 11 +++++------ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index 9eb5a23d..5abbcbfc 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -39,15 +39,14 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternTypeDash = PatternData::getPatternTypeDash(); $dirSep = PatternData::getDirSep(); - // set-up the names - $docFull = $name; // 00-colors.md - $doc = str_replace(".".$this->extProp,"",$docFull); // 00-colors + // make sure the pattern isn't hidden + $hidden = ($name[0] == "_"); + + // set-up the names, $name == 00-colors.md + $doc = str_replace(".".$this->extProp,"",$name); // 00-colors $docDash = $this->getPatternName(str_replace("_","",$doc),false); // colors $docPartial = $patternTypeDash."-".$docDash; - // make sure the pattern isn't hidden - $hidden = ($docFull[0] == "_"); - // if the pattern isn't hidden do stuff if (!$hidden) { diff --git a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php index 29eb5031..037bc5af 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php @@ -39,14 +39,13 @@ public function run($depth, $ext, $path, $pathName, $name) { // load default vars $patternTypeDash = PatternData::getPatternTypeDash(); - // set-up the names - $patternFull = $name; // foo.listitems.json - $pattern = str_replace(".listitems.".$ext,"",$patternFull); // foo - $patternDash = $this->getPatternName($pattern,false); // foo - $patternPartial = $patternTypeDash."-".$patternDash; // atoms-foo - // should this pattern get rendered? - $hidden = ($patternFull[0] == "_"); + $hidden = ($name[0] == "_"); + + // set-up the names, $name == foo.listitems.json + $pattern = str_replace(".listitems.".$ext,"",$name); // foo + $patternDash = $this->getPatternName($pattern,false); // foo + $patternPartial = $patternTypeDash."-".$patternDash; // atoms-foo if (!$hidden) { diff --git a/src/PatternLab/PatternData/Rules/PatternInfoRule.php b/src/PatternLab/PatternData/Rules/PatternInfoRule.php index 98fd0ff4..e02b6bad 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoRule.php @@ -39,15 +39,14 @@ public function run($depth, $ext, $path, $pathName, $name) { // load default vars $patternTypeDash = PatternData::getPatternTypeDash(); - // set-up the names - $patternFull = $name; // foo.json - $pattern = str_replace(".".$ext,"",$patternFull); // foo + // should this pattern get rendered? + $hidden = ($name[0] == "_"); + + // set-up the names, $name == foo.json + $pattern = str_replace(".".$ext,"",$name); // foo $patternDash = $this->getPatternName($pattern,false); // foo $patternPartial = $patternTypeDash."-".$patternDash; // atoms-foo - // should this pattern get rendered? - $hidden = ($patternFull[0] == "_"); - if (!$hidden) { $patternStoreData = array("category" => "pattern"); From cd08293109f4e7bd2903e69f91b6827ab55ba150 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:32:54 -0500 Subject: [PATCH 074/436] renaming the html loader to string loader to match it's real use --- src/PatternLab/Template.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index 6c17e373..abf4cf9a 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -23,8 +23,8 @@ class Template { protected static $patternHead; protected static $patternFoot; protected static $filesystemLoader; - protected static $htmlLoader; protected static $patternLoader; + protected static $stringLoader; /** * Set-up default vars @@ -62,7 +62,8 @@ public static function init() { $options["templatePath"] = $pluginDir."/".$styleguideKit."/views"; $options["partialsPath"] = $pluginDir."/".$styleguideKit."/views/partials"; self::$filesystemLoader = PatternEngine::getInstance()->getFileSystemLoader($options); - self::$htmlLoader = PatternEngine::getInstance()->getVanillaLoader(); + $stringLoaderClass = $patternEngineBasePath."\Loaders\StringLoader"; + self::$stringLoader = new $stringLoaderClass(); } @@ -104,9 +105,6 @@ public static function getFilesystemLoader() { /* * Get the html loader */ - public static function getHTMLLoader() { - return self::$htmlLoader; - } /* * Get the pattern loader @@ -127,6 +125,8 @@ public static function getPatternLoader() { */ public static function setPatternLoader($instance) { self::$patternLoader = $instance; + public static function getStringLoader() { + return self::$stringLoader; } } From 3e36c31593bd05e687fc1f0d3419339dcc862415 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:33:20 -0500 Subject: [PATCH 075/436] new filesystem loader set-up --- src/PatternLab/Template.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index abf4cf9a..cd405148 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -57,11 +57,16 @@ public static function init() { self::$patternHead = (file_exists($patternHeadPath)) ? file_get_contents($patternHeadPath) : ""; self::$patternFoot = (file_exists($patternFootPath)) ? file_get_contents($patternFootPath) : ""; - // add the generic loaders + // add the filesystemLoader + $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); + $filesystemLoaderClass = $patternEngineBasePath."\Loaders\FilesystemLoader"; + $options = array(); $options["templatePath"] = $pluginDir."/".$styleguideKit."/views"; $options["partialsPath"] = $pluginDir."/".$styleguideKit."/views/partials"; - self::$filesystemLoader = PatternEngine::getInstance()->getFileSystemLoader($options); + + self::$filesystemLoader = new $filesystemLoaderClass($options); + $stringLoaderClass = $patternEngineBasePath."\Loaders\StringLoader"; self::$stringLoader = new $stringLoaderClass(); From 8f14bf4c58977552ae0e4bf286fb49c130431213 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:33:32 -0500 Subject: [PATCH 076/436] removing pattern loader cruft --- src/PatternLab/Template.php | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index cd405148..0855a0bb 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -70,6 +70,9 @@ public static function init() { $stringLoaderClass = $patternEngineBasePath."\Loaders\StringLoader"; self::$stringLoader = new $stringLoaderClass(); + // i can't remember why i chose to implement the pattern loader directly in classes + // i figure i had a good reason which is why it's not showing up here + } /* @@ -110,26 +113,6 @@ public static function getFilesystemLoader() { /* * Get the html loader */ - - /* - * Get the pattern loader - */ - public static function getPatternLoader() { - - if (empty(self::$patternLoader)) { - Console::writeTag("error","pattern loader needs to be set before you can get it..."); - Console::writeError("try this first: Template::setPatternLoader(PatternEngine::getInstance()->getPatternLoader($options));"); - } - - return self::$patternLoader; - - } - - /* - * Get the pattern loader - */ - public static function setPatternLoader($instance) { - self::$patternLoader = $instance; public static function getStringLoader() { return self::$stringLoader; } From a581957807efd6d9ba8a908714d67fdf8a1452df Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:34:14 -0500 Subject: [PATCH 077/436] no longer need the render class --- src/PatternLab/Builder.php | 1 - .../PatternData/Helpers/PatternCodeHelper.php | 1 - src/PatternLab/Render.php | 64 ------------------- 3 files changed, 66 deletions(-) delete mode 100644 src/PatternLab/Render.php diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 7b94aef0..0ddb1230 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -22,7 +22,6 @@ use \PatternLab\PatternData\Exporters\PatternPathDestsExporter; use \PatternLab\PatternData\Exporters\ViewAllPathsExporter; use \PatternLab\PatternEngine; -use \PatternLab\Render; use \PatternLab\Template; use \PatternLab\Timer; use \Symfony\Component\Finder\Finder; diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 6f202399..7b6be198 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -16,7 +16,6 @@ use \PatternLab\Data; use \PatternLab\PatternData; use \PatternLab\PatternEngine; -use \PatternLab\Render; use \PatternLab\Template; use \PatternLab\Timer; diff --git a/src/PatternLab/Render.php b/src/PatternLab/Render.php deleted file mode 100644 index 965ea2d3..00000000 --- a/src/PatternLab/Render.php +++ /dev/null @@ -1,64 +0,0 @@ -render($filePath,$data); - return $pattern; - - } - - /** - * Renders a given mark-up (header) using Mustache and incorporating the provided data - * @param {String} the mark-up to be rendered - * @param {Array} the data related to the pattern - * - * @return {String} the mark-up as rendered by Mustache - */ - public static function Header($html,$data) { - - $header = Template::getHTMLLoader()->render($html,$data); - return $header; - - } - - /** - * Renders a given mark-up (footer) using Mustache and incorporating the provided data - * @param {String} the mark-up to be rendered - * @param {Array} the data related to the pattern - * - * @return {String} the mark-up as rendered by Mustache - */ - public static function Footer($html,$data) { - - $footer = Template::getHTMLLoader()->render($html,$data); - return $footer; - - } - -} From 26d9ef7e79037e2efa9d6531f682fc58e813835f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:37:28 -0500 Subject: [PATCH 078/436] adding string loader support --- src/PatternLab/Builder.php | 24 +++++++++++-------- .../PatternData/Helpers/PatternCodeHelper.php | 11 +++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 0ddb1230..7f8d9a68 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -275,10 +275,13 @@ protected function generateStyleguide() { // add the pattern lab specific mark-up $partials["patternLabHead"] = Render::Header(Template::getHTMLHead(),array("cacheBuster" => $partials["cacheBuster"])); $partials["patternLabFoot"] = Render::Footer(Template::getHTMLFoot(),array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData))); + $stringLoader = Template::getStringLoader(); - $header = Render::Header(Template::getPatternHead(),$partials); $code = Template::getFilesystemLoader()->render("viewall",$partials); - $footer = Render::Footer(Template::getPatternFoot(),$partials); + $partials["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); + $partials["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); + $header = $stringLoader->render(array("string" => Template::getPatternHead(), "data" => $partials)); + $footer = $stringLoader->render(array("string" => Template::getPatternFoot(), "data" => $partials)); $styleGuidePage = $header.$code.$footer; @@ -307,6 +310,7 @@ protected function generateViewAllPages() { $patternHead = Template::getPatternHead(); $patternFoot = Template::getPatternFoot(); $filesystemLoader = Template::getFilesystemLoader(); + $stringLoader = Template::getStringLoader(); // make sure the pattern dir exists if (!is_dir($patternPublicDir)) { @@ -330,13 +334,13 @@ protected function generateViewAllPages() { $patternData["patternPartial"] = "viewall-".$patternStoreData["typeDash"]."-".$patternStoreData["nameDash"]; // add the pattern lab specific mark-up - $partials["patternLabHead"] = Render::Header($htmlHead,array("cacheBuster" => $partials["cacheBuster"])); - $partials["patternLabFoot"] = Render::Footer($htmlFoot,array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData))); + $partials["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); + $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them - $header = Render::Header($patternHead,$partials); $code = $filesystemLoader->render("viewall",$partials); - $footer = Render::Footer($patternFoot,$partials); + $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); + $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); $viewAllPage = $header.$code.$footer; // if the pattern directory doesn't exist create it @@ -363,13 +367,13 @@ protected function generateViewAllPages() { $patternData["patternPartial"] = "viewall-".$patternStoreData["nameDash"]."-all"; // add the pattern lab specific mark-up - $partials["patternLabHead"] = Render::Header($htmlHead,array("cacheBuster" => $partials["cacheBuster"])); - $partials["patternLabFoot"] = Render::Footer($htmlFoot,array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData))); + $partials["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); + $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them - $header = Render::Header($patternHead,$partials); $code = $filesystemLoader->render("viewall",$partials); - $footer = Render::Footer($patternFoot,$partials); + $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); + $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); $viewAllPage = $header.$code.$footer; // if the pattern directory doesn't exist create it diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 7b6be198..2e35affe 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -41,6 +41,7 @@ public function run() { $htmlFoot = Template::getHTMLFoot(); $patternHead = Template::getPatternHead(); $patternFoot = Template::getPatternFoot(); + $stringLoader = Template::getStringLoader(); // load the pattern loader Template::setPatternLoader(PatternEngine::getInstance()->getPatternLoader($options)); @@ -71,15 +72,15 @@ public function run() { // add the pattern lab specific mark-up // set a default var $exportClean = (isset($options["exportClean"])) ? $options["exportClean"] : false; - $data["patternLabHead"] = (!$this->exportFiles) ? Render::Header($htmlHead,array("cacheBuster" => $data["cacheBuster"])) : ""; - $data["patternLabFoot"] = (!$this->exportFiles) ? Render::Footer($htmlFoot,array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData))) : ""; + $data["patternLabHead"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $data["cacheBuster"]))) : ""; + $data["patternLabFoot"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData)))) : ""; // figure out the source path for the pattern to render $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; - $header = (!$this->exportClean) ? Render::Header($patternHead,$data) : ""; - $code = Render::Pattern($srcPath,$data); - $footer = (!$this->exportClean) ? Render::Footer($patternFoot,$data) : ""; + $header = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternHead, "data" => $data)) : ""; + $code = $patternLoader->render(array("pattern" => $srcPath, "data" => $data)); + $footer = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternFoot, "data" => $data)) : ""; PatternData::setPatternOption($patternStoreKey,"header",$header); PatternData::setPatternOption($patternStoreKey,"code",$code); From ab3c7b4a02ad4dac73206f6bafd87610a2037140 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:38:18 -0500 Subject: [PATCH 079/436] updating file system loader support --- src/PatternLab/Builder.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 7f8d9a68..f5051c38 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -273,14 +273,13 @@ protected function generateStyleguide() { $patternData = array(); // add the pattern lab specific mark-up - $partials["patternLabHead"] = Render::Header(Template::getHTMLHead(),array("cacheBuster" => $partials["cacheBuster"])); - $partials["patternLabFoot"] = Render::Footer(Template::getHTMLFoot(),array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData))); + $filesystemLoader = Template::getFilesystemLoader(); $stringLoader = Template::getStringLoader(); - $code = Template::getFilesystemLoader()->render("viewall",$partials); $partials["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); $partials["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); $header = $stringLoader->render(array("string" => Template::getPatternHead(), "data" => $partials)); + $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $stringLoader->render(array("string" => Template::getPatternFoot(), "data" => $partials)); $styleGuidePage = $header.$code.$footer; @@ -338,8 +337,8 @@ protected function generateViewAllPages() { $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them - $code = $filesystemLoader->render("viewall",$partials); $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); + $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); $viewAllPage = $header.$code.$footer; @@ -371,8 +370,8 @@ protected function generateViewAllPages() { $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them - $code = $filesystemLoader->render("viewall",$partials); $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); + $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); $viewAllPage = $header.$code.$footer; From 11cdb722b618e8805ebb5b4c3eaa250cf94b7693 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:38:28 -0500 Subject: [PATCH 080/436] whitespace fix --- src/PatternLab/Builder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index f5051c38..4a0f17be 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -278,6 +278,7 @@ protected function generateStyleguide() { $partials["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); $partials["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); + $header = $stringLoader->render(array("string" => Template::getPatternHead(), "data" => $partials)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $stringLoader->render(array("string" => Template::getPatternFoot(), "data" => $partials)); From f051e66ad4e9582db9a6f3d953018f4ae71638b0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:38:45 -0500 Subject: [PATCH 081/436] adding support for pattern loader --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 2e35affe..2011ea73 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -44,7 +44,9 @@ public function run() { $stringLoader = Template::getStringLoader(); // load the pattern loader - Template::setPatternLoader(PatternEngine::getInstance()->getPatternLoader($options)); + $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); + $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; + $patternLoader = new $patternLoaderClass($options); $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { From a50bb1ae0ac3e68ab91abcd6d886217357959cce Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:38:53 -0500 Subject: [PATCH 082/436] whitespace fix --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 2011ea73..4f9d35f8 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -73,7 +73,7 @@ public function run() { // add the pattern lab specific mark-up // set a default var - $exportClean = (isset($options["exportClean"])) ? $options["exportClean"] : false; + $exportClean = (isset($options["exportClean"])) ? $options["exportClean"] : false; $data["patternLabHead"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $data["cacheBuster"]))) : ""; $data["patternLabFoot"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData)))) : ""; From 3ee2b3fee7c4c2cd17b6fb549d35f7a9c05d429b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:39:22 -0500 Subject: [PATCH 083/436] offer an error if patternengines.json doesn't exist --- src/PatternLab/PatternEngine.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/PatternEngine.php b/src/PatternLab/PatternEngine.php index ce8fda1a..7b42a0b4 100644 --- a/src/PatternLab/PatternEngine.php +++ b/src/PatternLab/PatternEngine.php @@ -76,6 +76,8 @@ public static function loadRules() { } + } else { + Console::writeError("The pattern engines list isn't available in ".$packagesDir."..."); } } From 7c7af85bdf3d9e70f5990e3afc3ce0d861b10813 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:39:39 -0500 Subject: [PATCH 084/436] read config once instead of in each time a pattern engine is checked --- src/PatternLab/PatternEngine.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternEngine.php b/src/PatternLab/PatternEngine.php index 7b42a0b4..bd620773 100644 --- a/src/PatternLab/PatternEngine.php +++ b/src/PatternLab/PatternEngine.php @@ -34,10 +34,11 @@ public static function getInstance() { public static function init() { $found = false; + $patternExtension = Config::getOption("patternExtension"); self::loadRules(); foreach (self::$rules as $rule) { - if ($rule->test()) { + if ($rule->test($patternExtension)) { self::$instance = $rule; $found = true; break; From d7c00aaf52258b4105032b371554494f4f385191 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:40:10 -0500 Subject: [PATCH 085/436] compare against the supplied test var --- src/PatternLab/PatternEngine/Rule.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/PatternEngine/Rule.php b/src/PatternLab/PatternEngine/Rule.php index ce8cb397..0dff0855 100644 --- a/src/PatternLab/PatternEngine/Rule.php +++ b/src/PatternLab/PatternEngine/Rule.php @@ -28,6 +28,9 @@ public function __construct() { public function test() { return ($this->engineProp == Config::getOption("patternExtension")); + public function test($patternExtension) { + + return ($this->engineProp === $patternExtension); } From 6c215c4bf7dddfa1aa4d4c8e4c7e5af9e6bed711 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:40:18 -0500 Subject: [PATCH 086/436] add support for a base path attribute --- src/PatternLab/PatternEngine/Rule.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternEngine/Rule.php b/src/PatternLab/PatternEngine/Rule.php index 0dff0855..a78adaad 100644 --- a/src/PatternLab/PatternEngine/Rule.php +++ b/src/PatternLab/PatternEngine/Rule.php @@ -18,6 +18,7 @@ class Rule { protected $engineProp; + protected $basePath; public function __construct() { @@ -25,9 +26,12 @@ public function __construct() { } - public function test() { + public function getBasePath() { - return ($this->engineProp == Config::getOption("patternExtension")); + return $this->basePath; + + } + public function test($patternExtension) { return ($this->engineProp === $patternExtension); From 4a7e6dfb1a5069fb1bb12720223df9a659e9fca9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 2 Jan 2015 15:40:33 -0500 Subject: [PATCH 087/436] generic loader class just in case --- src/PatternLab/PatternEngine/Loader.php | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/PatternLab/PatternEngine/Loader.php diff --git a/src/PatternLab/PatternEngine/Loader.php b/src/PatternLab/PatternEngine/Loader.php new file mode 100644 index 00000000..4cd4ff56 --- /dev/null +++ b/src/PatternLab/PatternEngine/Loader.php @@ -0,0 +1,28 @@ + Date: Fri, 2 Jan 2015 20:32:19 -0500 Subject: [PATCH 088/436] match *only* media queries --- src/PatternLab/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 4a0f17be..2cd481f7 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -60,7 +60,7 @@ protected function gatherMQs() { foreach ($finder as $file) { $data = file_get_contents($file->getPathname()); - preg_match_all("/(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches); + preg_match_all("/@media.*(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches); foreach ($matches[3] as $match) { if (!in_array($match,$mqs)) { $mqs[] = $match; From 7d77d4e8ea4e6935d559dead46b80dcf1e9368d5 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 7 Jan 2015 14:39:55 -0500 Subject: [PATCH 089/436] documenting new way to do handle component files --- src/PatternLab/InstallerUtil.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index c4d26deb..2c7806f1 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -139,6 +139,20 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat } */ + /* + iterate over a source or source dirs and copy files into the componentdir. + use file extensions to add them to the appropriate arrays below. so... + "patternlab": { + "dist": { + "componentDir": { + { "*": "*" } + } + } + "onready": "" + } + + } + /* patternlab-components/templates.json (read in via PHP and written out as data.json), loaded via AJAX for PHP: { "templates": [...] } From e974c46b3e6a718999ff44cf524349808930dcd2 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 7 Jan 2015 14:40:26 -0500 Subject: [PATCH 090/436] just in case i have to fall back updating props of the method --- src/PatternLab/InstallerUtil.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 2c7806f1..22727c9e 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -129,13 +129,13 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat NEED TO KNOW TYPES BEFORE MOVING, they just get mirrored "dist": { "componentDir": { // patternlab-components/package/name/ - "css": "css/*", // string or array + "css": "css/*", // string, object, or array "javascript": { // string, object, or array "files": // string or array "onready": // string } - "images": // string or array - "templates": // string or array + "images": // string, object or array + "templates": // string, object or array } */ From aaa50aed27fa5c19eb2f9ae4c4d00de821959a29 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 7 Jan 2015 14:40:32 -0500 Subject: [PATCH 091/436] typo fix --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 22727c9e..621c1d2f 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -156,7 +156,7 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat /* patternlab-components/templates.json (read in via PHP and written out as data.json), loaded via AJAX for PHP: { "templates": [...] } - for JS: var templates = [ { "pattern-lab/plugin-kss": [ "dist/templates/foo.mustache "] } ]; + for JS: var templates = [ { "pattern-lab/plugin-kss": [ "dist/templates/foo.mustache"] } ]; patternlab-components/javascript.json (read in via PHP and written out as data.json), $script uses the data.json to load the list of files for PHP: { "javascript": [...] }; for JS: var javascript = [ { "pattern-lab/plugin-kss": { "dependencies": [ "path.js" ], "onready": "code" } } ]; From f373513668dd46af0c0e5aa876adfc052c33b4c4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 9 Jan 2015 11:53:26 -0500 Subject: [PATCH 092/436] fixing the description for how files should be moved --- src/PatternLab/InstallerUtil.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 621c1d2f..b6211c79 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -83,11 +83,11 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas $destination = ($destination[strlen($destination)-1] == "/") ? substr($destination,0,-1) : $destination; // decide how to move the files. the rules: - // dest ~ src -> action - // * ~ * -> mirror to path/ - // path ~ * -> mirror to path/ - // path ~ foo/* -> mirror to path/foo - // path ~ foo/s.html -> copy tp path/foo/s.html + // src ~ dest -> action + // * ~ * -> mirror all in {srcroot}/ to {destroot}/ + // * ~ path/* -> mirror all in {srcroot}/ to {destroot}/path/ + // foo/* ~ path/* -> mirror all in {srcroot}/foo/ to {destroot}/path/ + // foo/s.html ~ path/k.html -> mirror {srcroot}/foo/s.html to {destroot}/path/k.html if (($source == "*") && ($destination == "*")) { if (!self::pathExists($packageName,$destinationBase."/")) { From c4c7f3453997e30d825bf9d482e96256bc5cffc9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 9 Jan 2015 16:24:19 -0500 Subject: [PATCH 093/436] making sure patternlab-components isn't cleaned --- src/PatternLab/FileUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index 07648d2d..b6cce7c4 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -182,7 +182,7 @@ public static function cleanPublic() { $sourceDirs = glob($sourceDir."/*",GLOB_ONLYDIR); // make sure some directories aren't deleted - $ignoreDirs = array("styleguide"); + $ignoreDirs = array("styleguide","patternlab-components"); foreach ($ignoreDirs as $ignoreDir) { $key = array_search($publicDir."/".$ignoreDir,$publicDirs); if ($key !== false){ From b96c8e939c80f5f4638ccf0b5ef3dcfe6e1b76dd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 26 Jan 2015 09:47:19 -0500 Subject: [PATCH 094/436] supporting extraOutput --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 2 +- src/PatternLab/PatternData/Rules/PatternRule.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 4f9d35f8..f4ee37f7 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -69,7 +69,7 @@ public function run() { $patternData["patternState"] = $patternStoreData["state"]; // extra copy for the code view - $patternData["patternDescAdditions"] = isset($patternStoreData["codeViewDescAdditions"]) ? $patternStoreData["codeViewDescAdditions"] : array(); + $patternData["extraOutput"] = isset($patternStoreData["extraOutput"]) ? $patternStoreData["extraOutput"] : array(); // add the pattern lab specific mark-up // set a default var diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index 68cc025c..3dfe8aed 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -90,7 +90,8 @@ public function run($depth, $ext, $path, $pathName, $name) { "isFile" => $this->isFileProp, "partialViewDescAdditions" => array(), "partialViewExampleAdditions" => array(), - "codeViewDescAdditions" => array()); + "extraHolder" => array(), + "extraOutput" => array()); // add any subtype info if necessary if ($depth == 2) { From 3eeac17fcc30739fd71fa9d6c1b1051b1ba7feed Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 26 Jan 2015 09:47:32 -0500 Subject: [PATCH 095/436] smarter installer to handle the * destination --- src/PatternLab/InstallerUtil.php | 182 ++++++++++++++++++------------- 1 file changed, 108 insertions(+), 74 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index b6211c79..267b4e70 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -79,7 +79,7 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas } // clean any * or / on the end of $destination - $destination = ($destination[strlen($destination)-1] == "*") ? substr($destination,0,-1) : $destination; + $destination = (($destination != "*") && ($destination[strlen($destination)-1] == "*")) ? substr($destination,0,-1) : $destination; $destination = ($destination[strlen($destination)-1] == "/") ? substr($destination,0,-1) : $destination; // decide how to move the files. the rules: @@ -117,31 +117,20 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas } /** - * Parse the component types to figure out what needs to be moved and added to the component JSON files + * Parse the component types to figure out what needs to be added to the component JSON files * @param {String} the name of the package * @param {String} the base directory for the source of the files * @param {String} the base directory for the destination of the files (publicDir or sourceDir) - * @param {Array} the list of files to be moved + * @param {Array} the list of files to be parsed for component types + * @param {String} template extension for templates + * @param {String} the javascript to run on ready + * @param {String} the javascript to run as a callback */ - protected static function parseComponentTypes($packageName,$sourceBase,$destinationBase,$componentTypes) { - - /* - NEED TO KNOW TYPES BEFORE MOVING, they just get mirrored - "dist": { - "componentDir": { // patternlab-components/package/name/ - "css": "css/*", // string, object, or array - "javascript": { // string, object, or array - "files": // string or array - "onready": // string - } - "images": // string, object or array - "templates": // string, object or array - } - */ + protected static function parseComponentList($packageName,$sourceBase,$destinationBase,$componentFileList,$templateExtension,$onready,$callback) { /* iterate over a source or source dirs and copy files into the componentdir. - use file extensions to add them to the appropriate arrays below. so... + use file extensions to add them to the appropriate type arrays below. so... "patternlab": { "dist": { "componentDir": { @@ -149,67 +138,112 @@ protected static function parseComponentTypes($packageName,$sourceBase,$destinat } } "onready": "" + "callback": "" + "templateExtension": "" } - } - /* - patternlab-components/templates.json (read in via PHP and written out as data.json), loaded via AJAX - for PHP: { "templates": [...] } - for JS: var templates = [ { "pattern-lab/plugin-kss": [ "dist/templates/foo.mustache"] } ]; - patternlab-components/javascript.json (read in via PHP and written out as data.json), $script uses the data.json to load the list of files - for PHP: { "javascript": [...] }; - for JS: var javascript = [ { "pattern-lab/plugin-kss": { "dependencies": [ "path.js" ], "onready": "code" } } ]; - patternlab-components/css.json (read in via PHP and written out as data.json), simple loader uses data.json to the load the list of files - for PHP: { "css": [...] }; - for JS: var css = [ { "pattern-lab/plugin-kss": [ "path1.css", "path2.css" ] } ]; */ - $destinationBase = $destinationBase."/".$packageName; + // decide how to type list files. the rules: + // src ~ dest -> action + // * ~ * -> iterate over all files in {srcroot}/ and create a type listing + // foo/* ~ path/* -> iterate over all files in {srcroot}/foo/ and create a type listing + // foo/s.html ~ path/k.html -> create a type listing for {srcroot}/foo/s.html - // check if css option is set - if (isset($componentTypes["css"])) { - - $fileList = self::buildFileList($componentTypes["css"]); - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); - self::updateComponentJSON("css",$componentTypes["css"]); - - } + // set-up component types store + $componentTypes = array("stylesheets" => array(), "javascripts" => array(), "templates" => array()); - // check if the javascript option is set - if (isset($componentList["javascript"])) { + // iterate over the file list + foreach ($componentFileList as $componentItem) { + + // retrieve the source & destination + $source = self::removeDots(key($componentItem)); + $destination = self::removeDots($componentItem[$source]); - // check to see if this has options - if (is_array($componentList["javascript"]) && (isset($componentTypes["javascript"]["files"]))) { - $fileList = self::buildFileList($componentList["javascript"]["files"]); - $javascriptList = $componentList["javascript"]["files"]; + if (($source == "*") || ($source[strlen($source)-1] == "*")) { + + // build the source & destination + $source = (strlen($source) > 2) ? rtrim($source,"/*") : ""; + $destination = (strlen($destination) > 2) ? rtrim($destination,"/*") : ""; + + // get files + $finder = new Finder(); + $finder->files()->in($sourceBase.$source); + + // iterate over the returned objects + foreach ($finder as $file) { + + $ext = $file->getExtension(); + + if ($ext == "css") { + $componentTypes["stylesheets"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); + } else if ($ext == "js") { + $componentTypes["javascripts"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); + } else if ($ext == $templateExtension) { + $componentTypes["templates"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); + } + + } + } else { - $fileList = self::buildFileList($componentList["javascript"]); - $javascriptList = $componentList["javascript"]; + + $bits = explode(".",$source); + + if (count($bits) > 0) { + + $ext = $bits[count($bits)-1]; + + if ($ext == "css") { + $componentTypes["stylesheets"][] = $destination; + } else if ($ext == "js") { + $componentTypes["javascripts"][] = $destination; + } else if ($ext == $templateExtension) { + $componentTypes["templates"][] = $destination; + } + + } + } - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); - self::updateComponentJSON("javascript",$javascriptList); - } - // check if the images option is set - if (isset($componentTypes["images"])) { - - $fileList = self::buildFileList($componentTypes["images"]); - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); - + /* + FOR USE AS A PACKAGE TO BE LOADED LATER + { + "name": "pattern-lab-plugin-kss", + "templates": { "filename": "filepath" }, // replace slash w/ dash in filename. replace extension + "stylesheets": [ ], + "javascripts": [ ], + "onready": "", + "callback": "" + } + */ + $packageInfo = array(); + $packageInfo["name"] = $packageName; + $packageInfo["templates"] = array(); + foreach ($componentTypes["templates"] as $templatePath) { + $templateKey = preg_replace("/\W/","-",str_replace(".".$templateExtension,"",$templatePath)); + $packageInfo["templates"][$templateKey] = $templatePath; + } + $packageInfo["stylesheets"] = $componentTypes["stylesheets"]; + $packageInfo["javascripts"] = $componentTypes["javascripts"]; + $packageInfo["onready"] = $onready; + $packageInfo["callback"] = $callback; + $packageInfoPath = Config::getOption("componentDir")."/packages/".str_replace("/","-",$packageName).".json"; + + // double-check the dirs are created + if (!is_dir(Config::getOption("componentDir"))) { + mkdir(Config::getOption("componentDir")); } - // check if the templates option is set - if (isset($componentList["templates"])) { - - $fileList = self::buildFileList($componentTypes["templates"]); - self::parseFileList($packageName,$sourceBase,$destinationBase,$fileList); - self::updateComponentJSON("templates",$componentTypes["templates"]); - + if (!is_dir(Config::getOption("componentDir")."/packages/")) { + mkdir(Config::getOption("componentDir")."/packages/"); } + // write out the package info + file_put_contents($packageInfoPath,json_encode($packageInfo)); + } /** @@ -224,18 +258,11 @@ protected static function parseFileList($packageName,$sourceBase,$destinationBas foreach ($fileList as $fileItem) { // retrieve the source & destination - $destination = self::removeDots(key($fileItem)); - $source = self::removeDots($fileItem[$destination]); + $source = self::removeDots(key($fileItem)); + $destination = self::removeDots($fileItem[$source]); // depending on the source handle things differently. mirror if it ends in /* - if (is_array($source)) { - foreach ($source as $key => $value) { - self::moveFiles($value,$key,$packageName,$sourceBase,$destinationBase); - } - } else { - self::moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase); - } - + self::moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase); } @@ -376,6 +403,8 @@ public static function prePackageUninstallCmd($event) { self::scanForPatternEngineRule($pathBase,true); } + // go over .json in patternlab-components/, remove references to packagename + } /** @@ -445,7 +474,12 @@ protected static function runTasks($event,$type) { // move assets to the components directory if (isset($extra["dist"]["componentDir"])) { - self::parseComponentTypes($name,$pathDist,Config::getOption("componentDir")."/".$name,$extra["dist"]["componentDir"]); + $templateExtension = isset($extra["templateExtension"]) ? $extra["templateExtension"] : "mustache"; + $onready = isset($extra["onready"]) ? $extra["onready"] : ""; + $callback = isset($extra["callback"]) ? $extra["callback"] : ""; + $componentDir = Config::getOption("componentDir"); + self::parseComponentList($name,$pathDist,$componentDir."/".$name,$extra["dist"]["componentDir"],$templateExtension,$onready,$callback); + self::parseFileList($name,$pathDist,$componentDir."/".$name,$extra["dist"]["componentDir"]); } // see if we need to modify the config From 1721ecee80157af909fde411fd075ffb720d8683 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 26 Jan 2015 09:47:56 -0500 Subject: [PATCH 096/436] build the package info for the front-end plugins --- src/PatternLab/Builder.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 2cd481f7..80919181 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -162,6 +162,31 @@ protected function generateIndex() { $viewAllPaths = $vapExporter->run($navItems); $output .= "var viewAllPaths = ".json_encode($viewAllPaths).";"; + // gather plugin package information + $packagesInfo = array(); + $componentDir = Config::getOption("componentDir"); + $componentPackagesDir = $componentDir."/packages"; + $finder = new Finder(); + $finder->files()->name("*.json")->in($componentPackagesDir); + $finder->sortByName(); + foreach ($finder as $file) { + $filename = $file->getFilename(); + if ($filename[0] != "_") { + $javascriptPaths = array(); + $packageInfo = json_decode(file_get_contents($file->getPathname()),true); + foreach ($packageInfo["templates"] as $templateKey => $templatePath) { + $templatePathFull = $componentDir."/".$packageInfo["name"]."/".$templatePath; + $packageInfo["templates"][$templateKey] = (file_exists($templatePathFull)) ? file_get_contents($templatePathFull) : ""; + } + foreach ($packageInfo["javascripts"] as $key => $javascriptPath) { + $javascriptPaths[] = "patternlab-components/".$packageInfo["name"]."/".$javascriptPath; + } + $packageInfo["javascripts"] = $javascriptPaths; + $packagesInfo[] = $packageInfo; + } + } + $output .= "var plugins = ".json_encode($packagesInfo).";"; + // write out the data file_put_contents($dataDir."/patternlab-data.js",$output); From 620d476dc215144b5343d041a00aca630e9a400b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 26 Jan 2015 10:20:23 -0500 Subject: [PATCH 097/436] if the packages dir doesn't exist create it --- src/PatternLab/Builder.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 80919181..d4d9af5a 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -166,6 +166,9 @@ protected function generateIndex() { $packagesInfo = array(); $componentDir = Config::getOption("componentDir"); $componentPackagesDir = $componentDir."/packages"; + if (!is_dir($componentDir."/packages")) { + mkdir($componentDir."/packages"); + } $finder = new Finder(); $finder->files()->name("*.json")->in($componentPackagesDir); $finder->sortByName(); From c090de9c93a8959a5736d7aa4e5d95b19e5c6bfd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 26 Jan 2015 10:28:39 -0500 Subject: [PATCH 098/436] fixing ishcontrolshide foreach --- src/PatternLab/Builder.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index d4d9af5a..1e0ca9d0 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -135,12 +135,14 @@ protected function generateIndex() { $output .= "var config = ".json_encode($config).";"; // load the ish Controls - $ishControlsHide = Config::getOption("ishControlsHide"); + $ishControls = array(); $controlsToHide = array(); - foreach ($ishControlsHide as $controlToHide) { - $controlsToHide[$controlToHide] = "true"; + $ishControlsHide = Config::getOption("ishControlsHide"); + if ($ishControlsHide) { + foreach ($ishControlsHide as $controlToHide) { + $controlsToHide[$controlToHide] = "true"; + } } - $ishControls = array(); $ishControls["ishControlsHide"] = $controlsToHide; $ishControls["mqs"] = $this->gatherMQs(); $output .= "var ishControls = ".json_encode($ishControls).";"; From 5fd59dd7059c492f6ba31fc75f2a6b4fa2058257 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 26 Jan 2015 10:28:50 -0500 Subject: [PATCH 099/436] making sure the component dir is built --- src/PatternLab/Builder.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 1e0ca9d0..8099034a 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -167,6 +167,9 @@ protected function generateIndex() { // gather plugin package information $packagesInfo = array(); $componentDir = Config::getOption("componentDir"); + if (!is_dir($componentDir)) { + mkdir($componentDir); + } $componentPackagesDir = $componentDir."/packages"; if (!is_dir($componentDir."/packages")) { mkdir($componentDir."/packages"); From 833e57c102d243892c1850814c422706ecd8b62e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 Feb 2015 18:43:59 -0500 Subject: [PATCH 100/436] using symfony to create the destination base --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 267b4e70..81a45494 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -75,7 +75,7 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas // make sure the destination base exists if (!is_dir($destinationBase)) { - mkdir($destinationBase); + self::$fs->mkdir($destinationBase); } // clean any * or / on the end of $destination From 712cbdeb7a7b78026be123173b9e121ba3e02c84 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 Feb 2015 19:23:33 -0500 Subject: [PATCH 101/436] trying to handle config options that are an array --- src/PatternLab/Config.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 44b08dfb..b4cda4c2 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -291,7 +291,7 @@ public static function setExposedOption($optionName = "") { */ public static function updateConfigOption($optionName,$optionValue) { - if (strpos($optionValue,"") !== false) { + if (is_string($optionValue) && strpos($optionValue,"") !== false) { // prompt for input using the supplied query $prompt = str_replace("","",str_replace("","",$optionValue)); @@ -309,7 +309,8 @@ public static function updateConfigOption($optionName,$optionValue) { } else if (self::$options["overrideConfig"] == "q") { // prompt for input - $prompt = "update the config option ".$optionName." with the value ".$optionValue."?"; + $optionValueOutput = is_array($optionValue) ? implode(", ",$optionValue) : $optionValue; + $prompt = "update the config option ".$optionName." with the value ".$optionValueOutput."?"; $options = "Y/n"; $input = Console::promptInput($prompt,$options); From 2afba0a9e86ba66ed0b9fcdbbb55d205ec73ecb8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 19 Feb 2015 16:10:57 -0500 Subject: [PATCH 102/436] removing a theme "color" that was causing the loop --- src/PatternLab/Console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 7c1ef005..0e6ec851 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -55,7 +55,7 @@ public static function init() { $colorTheme["info"] = "cyan"; $colorTheme["warning"] = "yellow"; $colorTheme["error"] = "red"; - $colorTheme["bold"] = "bold"; + $colorTheme["strong"] = "bold"; self::$color->setTheme($colorTheme); } From 85c57ddd569eb53c83d034775b2fe05297c37f54 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 19 Feb 2015 16:11:13 -0500 Subject: [PATCH 103/436] adding a line about getting more help for a command --- src/PatternLab/Console.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 0e6ec851..b002137c 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -295,6 +295,11 @@ public static function writeHelp() { self::writeLine(" --".$attributes["commandLong"].$spacer." ".$attributes["commandDesc"]."",true); } + // write out how to get more help + self::writeLine(""); + self::writeLine("

Get options for a specific command:

",true,true); + self::writeLine(" php ".self::$self." --help --command",true); + self::writeLine(""); } From c87f43c6c474bdcbe217e7049688c9b1efacbfe9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 23 Feb 2015 20:36:11 -0500 Subject: [PATCH 104/436] adding a dispatcher so an event can fire --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index f4ee37f7..f080ef46 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -14,6 +14,7 @@ use \PatternLab\Config; use \PatternLab\Data; +use \PatternLab\Dispatcher; use \PatternLab\PatternData; use \PatternLab\PatternEngine; use \PatternLab\Template; @@ -43,6 +44,8 @@ public function run() { $patternFoot = Template::getPatternFoot(); $stringLoader = Template::getStringLoader(); + // dispatch event + Dispatcher::getInstance()->dispatch("patternCodeHelper.rawPatternLoaded"); // load the pattern loader $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; From 43b3106961c96aa03c4b6750e1afd313d061ca40 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 23 Feb 2015 20:36:44 -0500 Subject: [PATCH 105/436] iterate over the pattern store and load in the pattern data --- .../PatternData/Helpers/PatternCodeHelper.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index f080ef46..7269f7fc 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -13,6 +13,7 @@ namespace PatternLab\PatternData\Helpers; use \PatternLab\Config; +use \PatternLab\Console; use \PatternLab\Data; use \PatternLab\Dispatcher; use \PatternLab\PatternData; @@ -38,12 +39,35 @@ public function run() { $options = array(); $options["patternPaths"] = $this->patternPaths; $patternExtension = Config::getOption("patternExtension"); + $patternSourceDir = Config::getOption("patternSourceDir"); $htmlHead = Template::getHTMLHead(); $htmlFoot = Template::getHTMLFoot(); $patternHead = Template::getPatternHead(); $patternFoot = Template::getPatternFoot(); $stringLoader = Template::getStringLoader(); + // load the pattern data + $store = PatternData::get(); + + // iterate to get raw data loaded into the PatternData Store + foreach ($store as $patternStoreKey => $patternStoreData) { + + if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { + + // figure out the source path for the pattern to render + $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; + + // load the raw data so it can be modified/rendered + if (file_exists($patternSourceDir."/".$srcPath.".".$patternExtension)) { + PatternData::setPatternOption($patternStoreKey,"patternRaw",file_get_contents($patternSourceDir."/".$srcPath.".".$patternExtension)); + } else { + Console::writeWarning($patternStoreData["partial"]." wasn't found for loading. i have no idea why... "); + } + + } + + } + // dispatch event Dispatcher::getInstance()->dispatch("patternCodeHelper.rawPatternLoaded"); // load the pattern loader From ca7d38ce456c6a232969b722199de0e02a311293 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 23 Feb 2015 20:36:56 -0500 Subject: [PATCH 106/436] grab the data again because it's been changed --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 7269f7fc..1a86af96 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -70,6 +70,10 @@ public function run() { // dispatch event Dispatcher::getInstance()->dispatch("patternCodeHelper.rawPatternLoaded"); + + // re-load the pattern data since we modified it + $store = PatternData::get(); + // load the pattern loader $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; From bda51a96881558411bef8601894afb39d11a6b48 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 23 Feb 2015 20:37:15 -0500 Subject: [PATCH 107/436] send a string to the pattern loader instead of a path --- .../PatternData/Helpers/PatternCodeHelper.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 1a86af96..81fa23e5 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -79,7 +79,7 @@ public function run() { $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; $patternLoader = new $patternLoaderClass($options); - $store = PatternData::get(); + // iterate to process each pattern foreach ($store as $patternStoreKey => $patternStoreData) { if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { @@ -108,16 +108,17 @@ public function run() { $data["patternLabHead"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $data["cacheBuster"]))) : ""; $data["patternLabFoot"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData)))) : ""; - // figure out the source path for the pattern to render - $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; - - $header = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternHead, "data" => $data)) : ""; - $code = $patternLoader->render(array("pattern" => $srcPath, "data" => $data)); - $footer = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternFoot, "data" => $data)) : ""; - - PatternData::setPatternOption($patternStoreKey,"header",$header); - PatternData::setPatternOption($patternStoreKey,"code",$code); - PatternData::setPatternOption($patternStoreKey,"footer",$footer); + if (isset($patternStoreData["patternRaw"])) { + + $header = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternHead, "data" => $data)) : ""; + $code = $patternLoader->render(array("pattern" => $patternStoreData["patternRaw"], "data" => $data)); + $footer = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternFoot, "data" => $data)) : ""; + + PatternData::setPatternOption($patternStoreKey,"header",$header); + PatternData::setPatternOption($patternStoreKey,"code",$code); + PatternData::setPatternOption($patternStoreKey,"footer",$footer); + + } } From f2a0b5cefd674876525592dcfb9bc4c04d2b08d4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:17:05 -0500 Subject: [PATCH 108/436] clear data store methods --- src/PatternLab/Annotations.php | 7 +++++++ src/PatternLab/Data.php | 7 +++++++ src/PatternLab/PatternData.php | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 330a5607..373c0ea8 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -25,6 +25,13 @@ class Annotations { protected static $store = array(); + /** + * Clear all of the data in the $store + */ + public static function clear() { + self::$store = array(); + } + /** * Gather data from annotations.js and *.md files found in source/_annotations * diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 807a86b4..2097117f 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -25,6 +25,13 @@ class Data { protected static $store = array(); protected static $reservedKeys = array("listItems","cacheBuster","link","patternSpecific","patternLabHead","patternLabFoot"); + /** + * Clear all of the data in the $store + */ + public static function clear() { + self::$store = array(); + } + /** * Gather data from any JSON and YAML files in source/_data * diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 876a121c..35ca128d 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -64,6 +64,13 @@ public static function checkPatternOption($patternStoreKey,$optionName) { } + /** + * Clear all of the data in the $store + */ + public static function clear() { + self::$store = array(); + } + /** * Check to see if the given pattern type has a pattern subtype associated with it * @param {String} the name of the pattern From 6207487f05eb3f0347d05237ad61807e83b43b5b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:38:33 -0500 Subject: [PATCH 109/436] use the filesystem component --- src/PatternLab/FileUtil.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index b6cce7c4..a2a8a67b 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -33,9 +33,9 @@ protected static function moveFile($s,$p) { $sourceDir = Config::getOption("sourceDir"); $publicDir = Config::getOption("publicDir"); - if (file_exists($sourceDir."/".$s)) { - copy($sourceDir."/".$s,$publicDir."/".$p); - } + $fs = new Filesystem(); + $fs->copy($sourceDir.DIRECTORY_SEPARATOR.$s,$publicDir.DIRECTORY_SEPARATOR.$p); + } /** From 63dc81a23f24958545c1c11437c29e525738d629 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:38:47 -0500 Subject: [PATCH 110/436] remove the auto reload as an option --- src/PatternLab/Console/Commands/WatchCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index 8aa51535..3aa627a6 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -28,7 +28,7 @@ public function __construct() { Console::setCommand($this->command,"Watch for changes and regenerate","The watch command builds Pattern Lab, watches for changes in source/ and regenerates Pattern Lab when there are any.","w"); Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To turn off the cacheBuster:","n"); - Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); + //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); } From 2187941b1a41072a0bff88414bba563d197e4ccb Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:41:10 -0500 Subject: [PATCH 111/436] handling the hand-off from watcher --- src/PatternLab/Generator.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index 34b75f3e..72659213 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -52,6 +52,8 @@ public function generate($options = array()) { $noCacheBuster = (isset($options["noCacheBuster"])) ? $options["noCacheBuster"] : false; $exportFiles = (isset($options["exportFiles"])) ? $options["exportFiles"] : false; $exportClean = (isset($options["exportClean"])) ? $options["exportClean"] : false; + $watchMessage = (isset($options["watchMessage"])) ? $options["watchMessage"] : false; + $watchVerbose = (isset($options["watchVerbose"])) ? $options["watchVerbose"] : false; if ($noCacheBuster) { Config::updateOption("cacheBuster",0); @@ -95,9 +97,12 @@ public function generate($options = array()) { // update the change time so the auto-reload will fire (doesn't work for the index and style guide) Util::updateChangeTime(); - Console::writeLine("your site has been generated..."); - - Timer::stop(); + if ($watchVerbose && $watchMessage) { + Console::writeLine($watchMessage); + } else { + Console::writeLine("your site has been generated..."); + Timer::stop(); + } } From 2dbf2add2acc6c547488c8557f609ea48e6cc40a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:44:19 -0500 Subject: [PATCH 112/436] commenting out deprecated reload info --- src/PatternLab/Watcher.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 951b28f8..18900b70 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -51,16 +51,16 @@ public function watch($options = array()) { } // set default attributes - $reload = (isset($options["autoReload"])) ? $options["autoReload"] : false; $moveStatic = (isset($options["moveStatic"])) ? $options["moveStatic"] : true; $noCacheBuster = (isset($options["noCacheBuster"])) ? $options["noCacheBuster"] : false; // automatically start the auto-refresh tool - if ($reload) { + // DEPRECATED + /*if ($reload) { $path = str_replace("lib".DIRECTORY_SEPARATOR."PatternLab","autoReloadServer.php",__DIR__); $fp = popen("php ".$path." -s", "r"); Console::writeLine("starting page auto-reload..."); - } + }*/ if ($noCacheBuster) { Config::updateOption("cacheBuster",0); @@ -239,10 +239,13 @@ public function watch($options = array()) { if (gc_enabled()) gc_collect_cycles(); // output anything the reload server might send our way + // DEPRECATED + /* if ($reload) { $output = fgets($fp, 100); if ($output != "\n") print $output; } + */ // pause for .05 seconds to give the CPU a rest usleep(50000); @@ -250,7 +253,8 @@ public function watch($options = array()) { } // close the auto-reload process, this shouldn't do anything - fclose($fp); + // DEPRECATED + // fclose($fp); } From d486c5c6cd2024e5191e63ea88d7b6e81137a0a5 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:44:41 -0500 Subject: [PATCH 113/436] properly referencing config for ignore options --- src/PatternLab/Watcher.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 18900b70..f6fbe78a 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -77,6 +77,8 @@ public function watch($options = array()) { // default vars $publicDir = Config::getOption("publicDir"); $sourceDir = Config::getOption("sourceDir"); + $ignoreExts = Config::getOption("ie"); + $ignoreDirs = Config::getOption("id"); // run forever while (true) { @@ -190,7 +192,7 @@ public function watch($options = array()) { // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored $fileName = str_replace($sourceDir.DIRECTORY_SEPARATOR,"",$name); - if (($fileName[0] != "_") && (!in_array($object->getExtension(),$this->ie)) && (!in_array($object->getFilename(),$this->id))) { + if (($fileName[0] != "_") && (!in_array($object->getExtension(),$ignoreExts)) && (!in_array($object->getFilename(),$ignoreDirs))) { // catch directories that have the ignored dir in their path $ignoreDir = $this->ignoreDir($fileName); From 33aee0a7de6ad50ee6cb0fe05c49bb81bdcafac1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:44:58 -0500 Subject: [PATCH 114/436] setting the correct class for ignoreDir method --- src/PatternLab/Watcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index f6fbe78a..794c5964 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -195,7 +195,7 @@ public function watch($options = array()) { if (($fileName[0] != "_") && (!in_array($object->getExtension(),$ignoreExts)) && (!in_array($object->getFilename(),$ignoreDirs))) { // catch directories that have the ignored dir in their path - $ignoreDir = $this->ignoreDir($fileName); + $ignoreDir = FileUtil::ignoreDir($fileName); // check to see if it's a new directory if (!$ignoreDir && $object->isDir() && !isset($o->$fileName) && !is_dir($publicDir."/".$fileName)) { From 405a90c1527bd18c13b5b1e62f89183165a64bac Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:45:20 -0500 Subject: [PATCH 115/436] spacing fix --- src/PatternLab/Watcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 794c5964..b21ca91b 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -75,8 +75,8 @@ public function watch($options = array()) { Console::writeLine("watching your site for changes..."); // default vars - $publicDir = Config::getOption("publicDir"); - $sourceDir = Config::getOption("sourceDir"); + $publicDir = Config::getOption("publicDir"); + $sourceDir = Config::getOption("sourceDir"); $ignoreExts = Config::getOption("ie"); $ignoreDirs = Config::getOption("id"); From 472a737fbcb8bf02dde0e1b493731f00fee6c222 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:47:04 -0500 Subject: [PATCH 116/436] properly handling all underscore dirs --- src/PatternLab/Watcher.php | 46 +++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index b21ca91b..bfc08b77 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -159,23 +159,37 @@ public function watch($options = array()) { } - // iterate over the data files and regenerate the entire site if they've changed - $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir."/_annotations/"), \RecursiveIteratorIterator::SELF_FIRST); - - // make sure dots are skipped - $objects->setFlags(\FilesystemIterator::SKIP_DOTS); - - foreach($objects as $name => $object) { - - $fileName = str_replace($sourceDir."/_annotations".DIRECTORY_SEPARATOR,"",$name); - $mt = $object->getMTime(); + // iterate over annotations, data, meta and any other _ dirs + $watchDirs = glob($sourceDir."/_*",GLOB_ONLYDIR); + foreach ($watchDirs as $watchDir) { - if (!isset($o->$fileName)) { - $o->$fileName = $mt; - $this->updateSite($fileName,"added"); - } else if ($o->$fileName != $mt) { - $o->$fileName = $mt; - $this->updateSite($fileName,"changed"); + if (str_replace($sourceDir."/","",$watchDir) != "_patterns") { + + // iterate over the data files and regenerate the entire site if they've changed + $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($watchDir), \RecursiveIteratorIterator::SELF_FIRST); + + // make sure dots are skipped + $objects->setFlags(\FilesystemIterator::SKIP_DOTS); + + foreach($objects as $name => $object) { + + $fileName = str_replace($sourceDir."/","",$name); + $mt = $object->getMTime(); + + if (!isset($o->$fileName)) { + $o->$fileName = $mt; + if ($c) { + $this->updateSite($fileName,"added"); + } + } else if ($o->$fileName != $mt) { + $o->$fileName = $mt; + if ($c) { + $this->updateSite($fileName,"changed"); + } + } + + } + } } From 4b60522c102da332594d55fd1ce0aa15efa63dc7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:48:08 -0500 Subject: [PATCH 117/436] handling the passing of options to generate --- src/PatternLab/Watcher.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index bfc08b77..39843199 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -36,6 +36,8 @@ public function __construct($config = array()) { // construct the parent parent::__construct($config); + $this->options = array(); + } /** @@ -54,6 +56,9 @@ public function watch($options = array()) { $moveStatic = (isset($options["moveStatic"])) ? $options["moveStatic"] : true; $noCacheBuster = (isset($options["noCacheBuster"])) ? $options["noCacheBuster"] : false; + // make sure a copy of the given options are saved for using when running generate + $this->options = $options; + // automatically start the auto-refresh tool // DEPRECATED /*if ($reload) { @@ -306,6 +311,12 @@ private function updateSite($fileName,$message,$verbose = true) { Console::writeLine($fileName." changed..."); } } + + $options = $this->options; + + $options["watchVerbose"] = $verbose; + $options["watchMessage"] = $watchMessage; + $options["moveStatic"] = false; } } From ec7c11932cc028413a6d8440a4c212d9069cb4b3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:48:52 -0500 Subject: [PATCH 118/436] swapping in generate directly --- src/PatternLab/Watcher.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 39843199..51e5a7f1 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -288,18 +288,6 @@ public function watch($options = array()) { */ private function updateSite($fileName,$message,$verbose = true) { - Data::gather(); - PatternData::gather(); - Annotations::gather(); - - $this->generateIndex(); - $this->generateStyleguide(); - $this->generateViewAllPages(); - $this->generatePatterns(); - $this->generateAnnotations(); - - Util::updateChangeTime(); - if ($verbose) { if ($message == "added") { Console::writeLine($fileName." was added to Pattern Lab. Reload the website to see this change in the navigation..."); @@ -317,6 +305,15 @@ private function updateSite($fileName,$message,$verbose = true) { $options["watchVerbose"] = $verbose; $options["watchMessage"] = $watchMessage; $options["moveStatic"] = false; + + // clear the various data stores for re-population + Data::clear(); + PatternData::clear(); + Annotations::clear(); + + $g = new Generator(); + $g->generate($options); + } } From 0035eeea8764ae4ac81b37140c329f5d1a6745e6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:49:09 -0500 Subject: [PATCH 119/436] updating the watch messaging --- src/PatternLab/Watcher.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 51e5a7f1..d8a29dfa 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -288,15 +288,16 @@ public function watch($options = array()) { */ private function updateSite($fileName,$message,$verbose = true) { + $watchMessage = ""; if ($verbose) { if ($message == "added") { - Console::writeLine($fileName." was added to Pattern Lab. Reload the website to see this change in the navigation..."); + $watchMessage = "".$fileName." was added to Pattern Lab. reload the website to see this change in the navigation..."; } elseif ($message == "removed") { - Console::writeLine($fileName." was removed from Pattern Lab. Reload the website to see this change reflected in the navigation..."); + $watchMessage = "".$fileName." was removed from Pattern Lab. reload the website to see this change reflected in the navigation..."; } elseif ($message == "hidden") { - Console::writeLine($fileName." was hidden from Pattern Lab. Reload the website to see this change reflected in the navigation..."); + $watchMessage = "".$fileName." was hidden from Pattern Lab. reload the website to see this change reflected in the navigation..."; } else { - Console::writeLine($fileName." changed..."); + $watchMessage = "".$fileName." changed..."; } } From c686a22d9188a2347c098458b81831a77ce677c9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 Feb 2015 21:49:17 -0500 Subject: [PATCH 120/436] spacing fix --- src/PatternLab/Watcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index d8a29dfa..c2690ea8 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -98,7 +98,7 @@ public function watch($options = array()) { $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS); foreach($patternObjects as $name => $object) { - + // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored $fileName = str_replace($sourceDir."/_patterns".DIRECTORY_SEPARATOR,"",$name); $fileNameClean = str_replace(DIRECTORY_SEPARATOR."_",DIRECTORY_SEPARATOR,$fileName); From ff0e02480c151a0781a42398db12ac682070323f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:38:06 -0500 Subject: [PATCH 121/436] handle setting needed config options based upon package type --- src/PatternLab/InstallerUtil.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 81a45494..31cfe56b 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -503,9 +503,13 @@ protected static function runTasks($event,$type) { // see if the package has a listener self::scanForListener($pathBase); - // see if the package is a pattern engine + // address other specific needs based on type if ($type == "patternlab-patternengine") { self::scanForPatternEngineRule($pathBase); + } else if ($type == "patternlab-starterkit") { + Config::updateConfigOption("starterKit",$name); + } else if ($type == "patternlab-styleguidekit") { + Config::updateConfigOption("styleguideKit",$name); } } From ad089c0d37441357a7e361e2b7c63a4b877f5e98 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:38:16 -0500 Subject: [PATCH 122/436] fix type --- src/PatternLab/Console/Commands/WatchCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index 3aa627a6..c7e03fed 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -26,7 +26,7 @@ public function __construct() { $this->command = "watch"; Console::setCommand($this->command,"Watch for changes and regenerate","The watch command builds Pattern Lab, watches for changes in source/ and regenerates Pattern Lab when there are any.","w"); - Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); + Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To turn off the cacheBuster:","n"); //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); From be26ec369c5743c37179fde92b98e88f207404f6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:38:44 -0500 Subject: [PATCH 123/436] adding deprecation notice --- src/PatternLab/Console/Commands/WatchCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index c7e03fed..59db57aa 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -38,11 +38,12 @@ public function run() { $options = array(); $options["moveStatic"] = (Console::findCommandOption("p|patternsonly")) ? false : true; $options["noCacheBuster"] = Console::findCommandOption("n|nocache"); - $options["autoReload"] = Console::findCommandOption("r|autoreload"); // load the generator $g = new Generator(); $g->generate($options); + // DEPRECATED + // $options["autoReload"] = Console::findCommandOption("r|autoreload"); // load the watcher $w = new Watcher(); From 070bd7b42de22f53caebac637703210d3eab0fd3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:39:10 -0500 Subject: [PATCH 124/436] adding support for a starterkit option to watch command --- .../Console/Commands/WatchCommand.php | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index 59db57aa..fb322c14 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -28,6 +28,7 @@ public function __construct() { Console::setCommand($this->command,"Watch for changes and regenerate","The watch command builds Pattern Lab, watches for changes in source/ and regenerates Pattern Lab when there are any.","w"); Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To turn off the cacheBuster:","n"); + Console::setCommandOption($this->command,"starterkit","Watch for changes to the StarterKit and copy to source/. The --starterkit flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:","s"); //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); } @@ -39,15 +40,28 @@ public function run() { $options["moveStatic"] = (Console::findCommandOption("p|patternsonly")) ? false : true; $options["noCacheBuster"] = Console::findCommandOption("n|nocache"); - // load the generator - $g = new Generator(); - $g->generate($options); // DEPRECATED // $options["autoReload"] = Console::findCommandOption("r|autoreload"); - // load the watcher - $w = new Watcher(); - $w->watch($options); + // see if the starterKit flag was passed so you know what dir to watch + if (Console::findCommandOption("s|starterkit")) { + + // load the starterkit watcher + $w = new Watcher(); + $w->watchStarterKit(); + + } else { + + // load the generator + $g = new Generator(); + $g->generate($options); + + // load the watcher + $w = new Watcher(); + $w->watch($options); + + } + } From d3dca7280dd6524e1c60dda9b96314437d7d3c50 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:39:29 -0500 Subject: [PATCH 125/436] adding support for watching a starterkit and moving files --- src/PatternLab/Watcher.php | 84 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index c2690ea8..0b8ece82 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -25,6 +25,8 @@ use \PatternLab\PatternData; use \PatternLab\Util; use \PatternLab\Timer; +use \Symfony\Component\Filesystem\Filesystem; +use \Symfony\Component\Filesystem\Exception\IOExceptionInterface; class Watcher extends Builder { @@ -317,4 +319,86 @@ private function updateSite($fileName,$message,$verbose = true) { } + public function watchStarterKit() { + + // double-checks options was properly set + $starterKit = Config::getOption("starterKit"); + if (!$starterKit) { + Console::writeError("need to have a StarterKit set in the config..."); + } + + // set-up the full starterkit path + $starterKitPath = Config::getOption("packagesDir").DIRECTORY_SEPARATOR.$starterKit.DIRECTORY_SEPARATOR."dist"; + + // default vars + $sourceDir = Config::getOption("sourceDir"); + $packagesDir = Config::getOption("packagesDir"); + + $fs = new Filesystem(); + + $c = false; // track that one loop through the pattern file listing has completed + $o = new \stdClass(); // create an object to hold the properties + $cp = new \stdClass(); // create an object to hold a clone of $o + + $o->patterns = new \stdClass(); + + Console::writeLine("watching your starterkit for changes..."); + + // run forever + while (true) { + + // clone the patterns so they can be checked in case something gets deleted + $cp = clone $o->patterns; + + $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($starterKitPath), \RecursiveIteratorIterator::SELF_FIRST); + + // make sure dots are skipped + $objects->setFlags(\FilesystemIterator::SKIP_DOTS); + + foreach ($objects as $name => $object) { + + // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored + $fileName = str_replace($starterKitPath.DIRECTORY_SEPARATOR,"",$name); + + // check to see if it's a new directory + if ($object->isDir() && !isset($o->$fileName) && !is_dir($starterKitPath."/".$fileName)) { + mkdir($sourceDir."/".$fileName); + $o->$fileName = "dir created"; // placeholder + Console::writeLine($fileName."/ directory was created..."); + } + + // check to see if it's a new file or a file that has changed + if (file_exists($name)) { + + $mt = $object->getMTime(); + if ($object->isFile() && !isset($o->$fileName) && !file_exists($sourceDir.DIRECTORY_SEPARATOR.$fileName)) { + $o->$fileName = $mt; + $fs->copy($starterKitPath.DIRECTORY_SEPARATOR.$fileName,$sourceDir.DIRECTORY_SEPARATOR.$fileName); + Console::writeInfo($fileName." added..."); + } else if ($object->isFile() && isset($o->$fileName) && ($o->$fileName != $mt)) { + $o->$fileName = $mt; + $fs->copy($starterKitPath.DIRECTORY_SEPARATOR.$fileName,$sourceDir.DIRECTORY_SEPARATOR.$fileName); + Console::writeInfo($fileName." changed..."); + } else if (!isset($o->fileName)) { + $o->$fileName = $mt; + } + + } else { + unset($o->$fileName); + } + + } + + $c = true; + + // taking out the garbage. basically killing mustache after each run. + if (gc_enabled()) gc_collect_cycles(); + + // pause for .05 seconds to give the CPU a rest + usleep(50000); + + } + + } + } From ae43e6159939cdd5d5ff401c1e342811c01553fd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:40:53 -0500 Subject: [PATCH 126/436] copy changes --- src/PatternLab/Watcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 0b8ece82..59fbacf8 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -324,7 +324,7 @@ public function watchStarterKit() { // double-checks options was properly set $starterKit = Config::getOption("starterKit"); if (!$starterKit) { - Console::writeError("need to have a StarterKit set in the config..."); + Console::writeError("need to have a starterkit set in the config..."); } // set-up the full starterkit path From 54ee16724b7409bfaea267709178908f16594e59 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 Feb 2015 21:41:13 -0500 Subject: [PATCH 127/436] double-check the starterKit path exists --- src/PatternLab/Watcher.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 59fbacf8..943d2120 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -329,6 +329,9 @@ public function watchStarterKit() { // set-up the full starterkit path $starterKitPath = Config::getOption("packagesDir").DIRECTORY_SEPARATOR.$starterKit.DIRECTORY_SEPARATOR."dist"; + if (!is_dir($starterKitPath)) { + Console::writeError("the starterkit doesn't seem to exist..."); + } // default vars $sourceDir = Config::getOption("sourceDir"); From 77c8b6ff916fe7fadd94d717cdf65576b83c5a7a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 10:58:36 -0500 Subject: [PATCH 128/436] copy update for comments --- src/PatternLab/PatternData.php | 45 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 35ca128d..f338d6be 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -184,7 +184,7 @@ public static function gather($options = array()) { } /** - * Return the overall store of PatternData + * Get the overall store of PatternData */ public static function get() { @@ -193,21 +193,21 @@ public static function get() { } /** - * Return the directory separator + * Get the directory separator */ public static function getDirSep() { return self::$dirSep; } /** - * Return the front meta bits (hidden and noviewall) + * GEt the front meta bits (hidden and noviewall) */ public static function getFrontMeta() { return self::$frontMeta; } /** - * Return a specific item from the store + * Get a specific item from the store * @param {String} the option to check */ public static function getOption($optionName) { @@ -221,7 +221,7 @@ public static function getOption($optionName) { } /** - * Return a specific item from a pattern in the store data + * Get a specific item from a pattern in the store data * @param {String} the name of the pattern * @param {String} the name of the option to get * @@ -238,7 +238,7 @@ public static function getPatternOption($patternStoreKey,$optionName) { } /** - * Return the pattern sub type + * Get the pattern sub type */ public static function getPatternSubtype() { @@ -251,7 +251,7 @@ public static function getPatternSubtype() { } /** - * Return the pattern sub type clean + * Get the pattern sub type clean */ public static function getPatternSubtypeClean() { @@ -264,7 +264,7 @@ public static function getPatternSubtypeClean() { } /** - * Return the pattern sub type dash + * Get the pattern sub type dash */ public static function getPatternSubtypeDash() { @@ -277,7 +277,7 @@ public static function getPatternSubtypeDash() { } /** - * Return the pattern sub type set + * Get the pattern sub type set */ public static function getPatternSubtypeSet() { @@ -290,7 +290,7 @@ public static function getPatternSubtypeSet() { } /** - * Return the pattern type + * Get the pattern type */ public static function getPatternType() { @@ -303,7 +303,7 @@ public static function getPatternType() { } /** - * Return the pattern type clean + * Get the pattern type clean */ public static function getPatternTypeClean() { @@ -316,7 +316,7 @@ public static function getPatternTypeClean() { } /** - * Return the pattern type dash + * Get the pattern type dash */ public static function getPatternTypeDash() { @@ -431,7 +431,8 @@ public static function setPatternSubOption($patternStoreKey,$optionName,$pattern } /** - * Return the pattern sub type + * Set the pattern subtype + * @param {String} the option value */ public static function setPatternSubtype($optionValue) { @@ -440,7 +441,8 @@ public static function setPatternSubtype($optionValue) { } /** - * Return the pattern sub type clean + * Set the pattern subtype clean + * @param {String} the option value */ public static function setPatternSubtypeClean($optionValue) { @@ -449,7 +451,8 @@ public static function setPatternSubtypeClean($optionValue) { } /** - * Return the pattern sub type dash + * Set the pattern subtype dash + * @param {String} the option value */ public static function setPatternSubtypeDash($optionValue) { @@ -458,7 +461,8 @@ public static function setPatternSubtypeDash($optionValue) { } /** - * Return the pattern sub type set + * Set the pattern subtype set + * @param {String} the option value */ public static function setPatternSubtypeSet($optionValue) { @@ -467,7 +471,8 @@ public static function setPatternSubtypeSet($optionValue) { } /** - * Return the pattern type + * Set the pattern type + * @param {String} the option value */ public static function setPatternType($optionValue) { @@ -476,7 +481,8 @@ public static function setPatternType($optionValue) { } /** - * Return the pattern type clean + * Set the pattern type clean + * @param {String} the option value */ public static function setPatternTypeClean($optionValue) { @@ -485,7 +491,8 @@ public static function setPatternTypeClean($optionValue) { } /** - * Return the pattern type dash + * Set the pattern type dash + * @param {String} the option value */ public static function setPatternTypeDash($optionValue) { From 20032daeddc050758b045b8736e9ac4cd1fbff61 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 10:59:07 -0500 Subject: [PATCH 129/436] get a particular rule from the rules store --- src/PatternLab/PatternData.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index f338d6be..abb13090 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -329,6 +329,18 @@ public static function getPatternTypeDash() { } /** + * Get a particular rule + * @param {String} the name of the pattern + */ + public static function getRule($ruleName) { + + if (isset(self::$rules[$ruleName])) { + return self::$rules[$ruleName]; + } + + return false; + + } * Load all of the rules related to Pattern Data */ public static function loadRules($options) { From fc9bb4de24818547c48a67082021a4510e92cbb3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 10:59:20 -0500 Subject: [PATCH 130/436] get all rules from the rule store --- src/PatternLab/PatternData.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index abb13090..86a46f0d 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -341,6 +341,17 @@ public static function getRule($ruleName) { return false; } + + /** + * Get all rules + */ + public static function getRules() { + + return self::$rules; + + } + + /** * Load all of the rules related to Pattern Data */ public static function loadRules($options) { From 33566a60dd31d1dfbd7c8f9c3ea6b101aee7ad09 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 10:59:45 -0500 Subject: [PATCH 131/436] put a rule into the rules store --- src/PatternLab/PatternData.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 86a46f0d..97366892 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -523,4 +523,14 @@ public static function setPatternTypeDash($optionValue) { } + /** + * Set a rule + * @param {String} the name of the rule + * @param {Object} the rule properties, guess this is a class too + */ + public static function setRule($ruleName, $rule) { + + self::$rules[$ruleName] = $rule; + + } } From 60f57275a58e24f59f6c1824491ebdaabf551f64 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 11:00:03 -0500 Subject: [PATCH 132/436] use the setRule method to set the rule --- src/PatternLab/PatternData.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 97366892..a4c035da 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -356,10 +356,11 @@ public static function getRules() { */ public static function loadRules($options) { foreach (glob(__DIR__."/PatternData/Rules/*.php") as $filename) { - $rule = str_replace(".php","",str_replace(__DIR__."/PatternData/Rules/","",$filename)); - if ($rule[0] != "_") { - $ruleClass = "\PatternLab\PatternData\Rules\\".$rule; - self::$rules[] = new $ruleClass($options); + $ruleName = str_replace(".php","",str_replace(__DIR__."/PatternData/Rules/","",$filename)); + if ($ruleName[0] != "_") { + $ruleClass = "\PatternLab\PatternData\Rules\\".$ruleName; + $rule = new $ruleClass($options); + self::setRule($ruleName, $rule); } } } From 5dbdbe0c9fa094161861787a05ef9a130a30aee6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 11:00:12 -0500 Subject: [PATCH 133/436] update a property for a given rule --- src/PatternLab/PatternData.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index a4c035da..b9a80ab0 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -534,4 +534,25 @@ public static function setRule($ruleName, $rule) { self::$rules[$ruleName] = $rule; } + + /** + * Update a property for a given rule + * @param {String} the name of the rule to update + * @param {String} the name of the property + * @param {String} the value of the property + * @param {String} the action that should be taken with the new value + * + * @return {Boolean} whether the update was successful + */ + public function updateRuleProp($ruleName, $propName, $propValue, $action = "or") { + + if ($rule != self::getRule($ruleName)) { + return false; + } + + $rule->updateProp($propName, $propValue, $action); + self::setRule($ruleName, $rule); + + } + } From 9d5e5fbb3b5b17e2f4ec879e8134cbce9b3f45e8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 11:00:34 -0500 Subject: [PATCH 134/436] get a property for a rule --- src/PatternLab/PatternData/Rule.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/PatternLab/PatternData/Rule.php b/src/PatternLab/PatternData/Rule.php index 0b2c0cc5..3e0b4557 100644 --- a/src/PatternLab/PatternData/Rule.php +++ b/src/PatternLab/PatternData/Rule.php @@ -107,4 +107,19 @@ protected function getPatternName($pattern, $clean = true) { return ($clean) ? (str_replace("-"," ",$patternName)) : $patternName; } + /** + * Get the value for a property on the current PatternData rule + * @param {String} the name of the property + * + * @return {Boolean} whether the set was successful + */ + public function getProp($propName) { + + if (isset($this->$propName)) { + return $this->$propName; + } + + return false; + + } } From 9f7e138acc6c6ce083885e6ac9c42d5efa3da80b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 11:00:44 -0500 Subject: [PATCH 135/436] set a property for a rule --- src/PatternLab/PatternData/Rule.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/PatternLab/PatternData/Rule.php b/src/PatternLab/PatternData/Rule.php index 3e0b4557..014cdbcf 100644 --- a/src/PatternLab/PatternData/Rule.php +++ b/src/PatternLab/PatternData/Rule.php @@ -122,4 +122,19 @@ public function getProp($propName) { return false; } + + /** + * Set a value for a property on the current PatternData rule + * @param {String} the name of the property + * @param {String} the value of the property + * + * @return {Boolean} whether the set was successful + */ + public function setProp($propName, $propValue) { + + $this->$propName = $this->$propValue; + return true; + + } + } From 8aa9b18035dba2e938db893e2dc55f62cd56fc36 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 11:01:00 -0500 Subject: [PATCH 136/436] update a property for the given rule --- src/PatternLab/PatternData/Rule.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/PatternLab/PatternData/Rule.php b/src/PatternLab/PatternData/Rule.php index 014cdbcf..54d9fb9d 100644 --- a/src/PatternLab/PatternData/Rule.php +++ b/src/PatternLab/PatternData/Rule.php @@ -137,4 +137,32 @@ public function setProp($propName, $propValue) { } + /** + * Update a property on a given rule + * @param {String} the name of the property + * @param {String} the value of the property + * @param {String} the action that should be taken with the new value + * + * @return {Boolean} whether the update was successful + */ + public function updateProp($propName, $propValue, $action = "or") { + + if (!isset($this->$propName) || !is_scalar($propValue)) { + return false; + } + + if ($action == "or") { + + $propValue = $this->$propName."||".$propValue; + + } else if ($action == "and") { + + $propValue = $this->$propName."&&".$propValue; + + } + + return $this->setProp($this->$propName,$propValue); + + } + } From e541b99c2d9029f9ec9dabfcf94050011c5a2b7a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 11:13:43 -0500 Subject: [PATCH 137/436] separate out the parsing of composer extra to another function now can use it in fetch just to get the file location --- src/PatternLab/InstallerUtil.php | 115 ++++++++++++++++--------------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 31cfe56b..b0a2859c 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -116,6 +116,65 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas } + /** + * Parse the extra section from composer.json + * @param {Object} the JSON for the composer extra section + */ + public static function parseComposerExtraList($composerExtra) { + + // move assets to the base directory + if (isset($composerExtra["dist"]["baseDir"])) { + self::parseFileList($name,$pathDist,Config::getOption("baseDir"),$composerExtra["dist"]["baseDir"]); + } + + // move assets to the public directory + if (isset($composerExtra["dist"]["publicDir"])) { + self::parseFileList($name,$pathDist,Config::getOption("publicDir"),$composerExtra["dist"]["publicDir"]); + } + + // move assets to the source directory + if (isset($composerExtra["dist"]["sourceDir"])) { + self::parseFileList($name,$pathDist,Config::getOption("sourceDir"),$composerExtra["dist"]["sourceDir"]); + } + + // move assets to the scripts directory + if (isset($composerExtra["dist"]["scriptsDir"])) { + self::parseFileList($name,$pathDist,Config::getOption("scriptsDir"),$composerExtra["dist"]["scriptsDir"]); + } + + // move assets to the data directory + if (isset($composerExtra["dist"]["dataDir"])) { + self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$composerExtra["dist"]["dataDir"]); + } + + // move assets to the components directory + if (isset($composerExtra["dist"]["componentDir"])) { + $templateExtension = isset($composerExtra["templateExtension"]) ? $composerExtra["templateExtension"] : "mustache"; + $onready = isset($composerExtra["onready"]) ? $composerExtra["onready"] : ""; + $callback = isset($composerExtra["callback"]) ? $composerExtra["callback"] : ""; + $componentDir = Config::getOption("componentDir"); + self::parseComponentList($name,$pathDist,$componentDir."/".$name,$composerExtra["dist"]["componentDir"],$templateExtension,$onready,$callback); + self::parseFileList($name,$pathDist,$componentDir."/".$name,$composerExtra["dist"]["componentDir"]); + } + + // see if we need to modify the config + if (isset($composerExtra["config"])) { + + foreach ($composerExtra["config"] as $optionInfo) { + + // get config info + $option = key($optionInfo); + $value = $optionInfo[$option]; + + // update the config option + Config::updateConfigOption($option,$value); + + } + + } + + } + /** * Parse the component types to figure out what needs to be added to the component JSON files * @param {String} the name of the package @@ -441,62 +500,10 @@ protected static function runTasks($event,$type) { // make sure we're only evaluating pattern lab packages if (strpos($type,"patternlab-") !== false) { - // make sure that it has the name-spaced section of data to be parsed + // make sure that it has the name-spaced section of data to be parsed. if it exists parse it if (isset($extra["patternlab"])) { - // rebase $extra - $extra = $extra["patternlab"]; - - // move assets to the base directory - if (isset($extra["dist"]["baseDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("baseDir"),$extra["dist"]["baseDir"]); - } - - // move assets to the public directory - if (isset($extra["dist"]["publicDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("publicDir"),$extra["dist"]["publicDir"]); - } - - // move assets to the source directory - if (isset($extra["dist"]["sourceDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("sourceDir"),$extra["dist"]["sourceDir"]); - } - - // move assets to the scripts directory - if (isset($extra["dist"]["scriptsDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("scriptsDir"),$extra["dist"]["scriptsDir"]); - } - - // move assets to the data directory - if (isset($extra["dist"]["dataDir"])) { - self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$extra["dist"]["dataDir"]); - } - - // move assets to the components directory - if (isset($extra["dist"]["componentDir"])) { - $templateExtension = isset($extra["templateExtension"]) ? $extra["templateExtension"] : "mustache"; - $onready = isset($extra["onready"]) ? $extra["onready"] : ""; - $callback = isset($extra["callback"]) ? $extra["callback"] : ""; - $componentDir = Config::getOption("componentDir"); - self::parseComponentList($name,$pathDist,$componentDir."/".$name,$extra["dist"]["componentDir"],$templateExtension,$onready,$callback); - self::parseFileList($name,$pathDist,$componentDir."/".$name,$extra["dist"]["componentDir"]); - } - - // see if we need to modify the config - if (isset($extra["config"])) { - - foreach ($extra["config"] as $optionInfo) { - - // get config info - $option = key($optionInfo); - $value = $optionInfo[$option]; - - // update the config option - Config::updateConfigOption($option,$value); - - } - - } + self::parseComposerExtraList($extra["patternlab"]); } From 7950eeaa4f93ce18eef6e8190944b76003db51dd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 12:08:08 -0500 Subject: [PATCH 138/436] handle merging of array-based config info --- src/PatternLab/Config.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index b4cda4c2..7d9d2550 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -339,7 +339,12 @@ public static function updateOption($optionName = "", $optionValue = "") { } if (array_key_exists($optionName,self::$options)) { - self::$options[$optionName] = $optionValue; + if (is_array(self::$options[$optionName])) { + $optionValue = is_array($optionValue) ? $optionValue : array($optionValue); + self::$options[$optionName] = array_merge(self::$options[$optionName], $optionValue); + } else { + self::$options[$optionName] = $optionValue; + } return true; } @@ -360,7 +365,13 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { } catch (ParseException $e) { Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); } - $options[$optionName] = $optionValue; + + if (is_array($options[$optionName])) { + $optionValue = is_array($optionValue) ? $optionValue : array($optionValue); + $options[$optionName] = array_merge($options[$optionName], $optionValue); + } else { + $options[$optionName] = $optionValue; + } // dump the YAML $configOutput = Yaml::dump($options, 3); From bde2d55da8686cbaa80e97bd29bc90fa5c89ee2c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:35:24 -0500 Subject: [PATCH 139/436] zippy extensions --- src/PatternLab/Zippy/UnpackAdapter.php | 28 +++++++++++++++++ src/PatternLab/Zippy/UnpackFileStrategy.php | 34 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/PatternLab/Zippy/UnpackAdapter.php create mode 100644 src/PatternLab/Zippy/UnpackFileStrategy.php diff --git a/src/PatternLab/Zippy/UnpackAdapter.php b/src/PatternLab/Zippy/UnpackAdapter.php new file mode 100644 index 00000000..b6230ddc --- /dev/null +++ b/src/PatternLab/Zippy/UnpackAdapter.php @@ -0,0 +1,28 @@ +container = AdapterContainer::load(); + } + + public function getAdapters() { + return array(UnpackAdapter::newInstance($this->container['executable-finder'],$this->container['resource-manager'],$this->container['gnu-tar.inflator'],$this->container['gnu-tar.deflator'])); + } + + public function getFileExtension() { + return 'tar.gz'; + } + +} \ No newline at end of file From d7cb90830a6fbd191dcb7bea770400d0ab7ab347 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:36:13 -0500 Subject: [PATCH 140/436] making sure required vars are passed --- src/PatternLab/InstallerUtil.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index b0a2859c..761b895a 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -120,7 +120,7 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas * Parse the extra section from composer.json * @param {Object} the JSON for the composer extra section */ - public static function parseComposerExtraList($composerExtra) { + public static function parseComposerExtraList($composerExtra, $name, $pathDist) { // move assets to the base directory if (isset($composerExtra["dist"]["baseDir"])) { @@ -502,9 +502,7 @@ protected static function runTasks($event,$type) { // make sure that it has the name-spaced section of data to be parsed. if it exists parse it if (isset($extra["patternlab"])) { - - self::parseComposerExtraList($extra["patternlab"]); - + self::parseComposerExtraList($extra["patternlab"], $name, $pathDist); } // see if the package has a listener From bee06ab9b66cada25d69aece1bc389bb8fc98321 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:36:23 -0500 Subject: [PATCH 141/436] updating prompt copy --- src/PatternLab/InstallerUtil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 761b895a..60e84d90 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -366,12 +366,12 @@ protected static function pathExists($packageName,$path) { if ($prompt) { // prompt for input using the supplied query - $prompt = "the path ".$humanReadablePath." already exists. overwrite it with the contents from the ".$packageName." package?"; + $prompt = "the path ".$humanReadablePath." already exists. merge and possibly overwrite it the with contents from the ".$packageName." package?"; $options = "Y/n"; $input = Console::promptInput($prompt,$options); if ($input == "y") { - Console::writeTag("ok","contents of ".$humanReadablePath." being overwritten...", false, true); + Console::writeTag("ok","contents of ".$humanReadablePath." are being replaced and may be overwritten...", false, true); return false; } else { Console::writeWarning("contents of ".$humanReadablePath." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, true); From e9b649d421d3c44bea41e265aa8e82d890519c5f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:36:46 -0500 Subject: [PATCH 142/436] updating Fetch to support StarterKits --- src/PatternLab/Fetch.php | 138 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 80513303..83cbe177 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -12,8 +12,14 @@ namespace PatternLab; +use \Alchemy\Zippy\Zippy; +use \PatternLab\Config; use \PatternLab\Console; +use \PatternLab\InstallerUtil; use \PatternLab\Timer; +use \PatternLab\Zippy\UnpackFileStrategy; +use \Symfony\Component\Filesystem\Filesystem; +use \Symfony\Component\Filesystem\Exception\IOExceptionInterface; class Fetch { @@ -23,15 +29,143 @@ class Fetch { * * @return {String} the modified file contents */ - public function fetch($package = "") { + public function fetchPackage($package = "") { if (empty($package)) { Console::writeError("please provide a path for the package before trying to fetch it..."); } - + // run composer $composerPath = Config::getOption("coreDir").DIRECTORY_SEPARATOR."bin/composer.phar"; passthru("php ".$composerPath." require ".$package); + + } + + /** + * Fetch a package from GitHub + * @param {String} the command option to provide the rule for + * @param {String} the path to the package to be downloaded + * + * @return {String} the modified file contents + */ + public function fetchStarterKit($starterkit = "") { + + // double-checks options was properly set + if (empty($starterkit)) { + Console::writeError("please provide a path for the starterkit before trying to fetch it..."); + } + + // set default attributes + $sourceDir = Config::getOption("sourceDir"); + $tempDir = sys_get_temp_dir(); + $tempDirSK = $tempDir.DIRECTORY_SEPARATOR."pl-sk-archive"; + $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist" + $tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR."composer.json"; + + $fs = new Filesystem(); + + // figure out the options for the GH path + list($org,$repo,$tag) = $this->getPackageInfo($starterkit); + + //get the path to the GH repo and validate it + $tarballUrl = "https://github.com/".$org."/".$repo."/archive/".$tag.".tar.gz"; + + Console::writeInfo("downloading the starterkit..."); + + // try to download the given package + if (!$package = @file_get_contents($tarballUrl)) { + $error = error_get_last(); + Console::writeError("the starterkit wasn't downloaded because:\n\n ".$error["message"]); + } + + // write the package to the temp directory + $tempFile = tempnam($tempDir, "pl-sk-archive.tar.gz"); + file_put_contents($tempFile, $package); + + Console::writeInfo("installing the starterkit..."); + + // see if the source directory is empty + $emptyDir = true; + if (is_dir($sourceDir)) { + $objects = new \DirectoryIterator($sourceDir); + foreach ($objects as $object) { + if (!$object->isDot() && ($object->getFilename() != "README") && ($object->getFilename() != ".DS_Store")) { + $emptyDir = false; + } + } + } + + // if source directory isn't empty ask if it's ok to nuke what's there + if (!$emptyDir) { + + $prompt = "a starterkit is already installed. merge or replace?"; + $options = "M/r"; + $input = Console::promptInput($prompt,$options); + + if ($answer == "r") { + Console::writeWarning("deleting the old files before installing the new starterkit..."); + $fs->remove($checkDir); + } + + } + + // make sure the temp dir exists before copying into it + if (!is_dir($tempDirSK)) { + mkdir($tempDirSK); + } + + // extract, if the zip is supposed to be unpacked do that (e.g. stripdir) + $zippy = Zippy::load(); + $zippy->addStrategy(new UnpackFileStrategy()); + $zipAdapter = $zippy->getAdapterFor('tar.gz'); + $archiveZip = $zipAdapter->open($tempFile); + $archiveZip = $archiveZip->extract($tempDirSK); + + // thrown an error if temp/dist/ doesn't exist + if (!is_dir($tempDirDist)) { + Console::writeError("the starterkit needs to contain a dist/ directory before it can be installed..."); + } + + // check for composer.json. if it exists use it for determining things. otherwise just mirror dist/ to source/ + if (file_exists($tempComposerFile)) { + $tempComposerJSON = json_decode(file_get_contents($tempComposerFile), true); + InstallerUtil::parseComposerExtraList($tempComposerJSON, $starterkit, $tempDirDist) + } else { + $fs->mirror($tempDirDist, $sourceDir); + } + + // remove the temp files + Console::writeInfo("cleaning up the temp files..."); + $fs->remove($tempFile); + $fs->remove($tempDir); + + Console::writeInfo("the starterkit installation is complete..."); + + } + + /** + * Break up the package path + * @param {String} path of the GitHub repo + * + * @return {Array} the parts of the package path + */ + protected function getPackageInfo($package) { + + $org = ""; + $repo = ""; + $tag = "master"; + + if (strpos($package, "#") !== false) { + list($package,$tag) = explode("#",$package); + } + + if (strpos($package, "/") !== false) { + list($org,$repo) = explode("/",$package); + } else { + Console::writeError("please provide a real path to a package..."); + } + + return array($org,$repo,$tag); } From 69709d4a5745ac87c9da005abf8c417bf80bc587 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:37:19 -0500 Subject: [PATCH 143/436] adding support for fetching StarterKits to the fetch command --- .../Console/Commands/FetchCommand.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/PatternLab/Console/Commands/FetchCommand.php b/src/PatternLab/Console/Commands/FetchCommand.php index c2c9157f..30ccdb8f 100644 --- a/src/PatternLab/Console/Commands/FetchCommand.php +++ b/src/PatternLab/Console/Commands/FetchCommand.php @@ -22,17 +22,19 @@ public function __construct() { parent::__construct(); - $this->command = "fetch:"; + $this->command = "fetch"; - Console::setCommand($this->command,"Fetch a package","The fetch command loads a package and its dependencies from Packagist.","f:"); - Console::setCommandSample($this->command,"To fetch a package from Packagist:",""); + Console::setCommand($this->command,"Fetch a package or StarterKit","The fetch command downloads packages and StarterKits.","f"); + Console::setCommandOption($this->command,"package:","Fetch a package from Packagist.","To fetch a package from Packagist:","p:",""); + Console::setCommandOption($this->command,"starterkit:","Fetch a StarterKit from GitHub.","To fetch a StarterKit from GitHub:","s:",""); } public function run() { // find the value given to the command - $package = Console::findCommandValue("f|fetch"); + $package = Console::findCommandValue("p|package"); + $starterkit = Console::findCommandValue("s|starterkit"); if ($package) { @@ -50,7 +52,13 @@ public function run() { // run composer via fetch $f = new Fetch(); - $f->fetch($package); + $f->fetchPackage($package); + + } else if ($starterkit) { + + // download the starterkit + $f = new Fetch(); + $f->fetchStarterKit($starterkit); } else { @@ -58,8 +66,6 @@ public function run() { } - - } } From f651fb7ead2cd52528f282b4ccb37276a4331e8a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:37:30 -0500 Subject: [PATCH 144/436] requiring zippy --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c52de10e..b8670222 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "symfony/filesystem": "v2.5.0", "symfony/finder": "v2.5.3", "kevinlebrun/colors.php": "0.*", - "pattern-lab/unified-asset-installer": "dev-dev" + "pattern-lab/unified-asset-installer": "dev-dev", + "alchemy/zippy": "~0.2.1" } } From d4bebf823d98d8fe079cc880a67f85881ea4744c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 14:48:08 -0500 Subject: [PATCH 145/436] adding the starterkit command --- .../Console/Commands/StarterKitCommand.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/PatternLab/Console/Commands/StarterKitCommand.php diff --git a/src/PatternLab/Console/Commands/StarterKitCommand.php b/src/PatternLab/Console/Commands/StarterKitCommand.php new file mode 100644 index 00000000..9e9c23fc --- /dev/null +++ b/src/PatternLab/Console/Commands/StarterKitCommand.php @@ -0,0 +1,58 @@ +command = "starterkit"; + + Console::setCommand($this->command,"Initialize or fetch a specific StarterKit","The StarterKit command downloads StarterKits.","k"); + Console::setCommandOption($this->command,"init","Initialize with a blank StarterKit based on the active PatternEngine.","To initialize your project with a base StarterKit:","i"); + Console::setCommandOption($this->command,"fetch:","Fetch a specific StarterKit from GitHub.","To fetch a StarterKit from GitHub:","f:",""); + + } + + public function run() { + + // find the value given to the command + $init = Console::findCommandValue("i|init"); + $starterkit = Console::findCommandValue("f|fetch"); + + if ($init) { + $patternEngine = Config::getOption("patternExtension"); + $starterkit = "pattern-lab/starterkit-".$patternEngine."-base"; + } + + if ($starterkit) { + + // download the starterkit + $f = new Fetch(); + $f->fetchStarterKit($starterkit); + + } else { + + Console::writeHelpCommand($this->command); + + } + + } + +} From bd2bc698781d17ebd2c33855cab45d5840e5932a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 15:03:04 -0500 Subject: [PATCH 146/436] only prompt if the values have changed --- src/PatternLab/Config.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 7d9d2550..0051e6e1 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -308,17 +308,24 @@ public static function updateConfigOption($optionName,$optionValue) { } else if (self::$options["overrideConfig"] == "q") { - // prompt for input - $optionValueOutput = is_array($optionValue) ? implode(", ",$optionValue) : $optionValue; - $prompt = "update the config option ".$optionName." with the value ".$optionValueOutput."?"; - $options = "Y/n"; - $input = Console::promptInput($prompt,$options); + // standardize the values for comparison + $currentOptionValue = is_array(self::$options[$optionName]) ? implode(", ",self::$options[$optionName]) : self::$options[$optionName]; + $newOptionValue = is_array($optionValue) ? implode(", ",$optionValue) : $optionValue; - if ($input == "y") { - self::writeUpdateConfigOption($optionName,$optionValue); - Console::writeInfo("config option ".$optionName." updated...", false, true); - } else { - Console::writeWarning("config option ".$optionName." not updated...", false, true); + if ($currentOptionValue != $newOptionValue) { + + // prompt for input + $prompt = "update the config option ".$optionName." with the value ".$newOptionValue."?"; + $options = "Y/n"; + $input = Console::promptInput($prompt,$options); + + if ($input == "y") { + self::writeUpdateConfigOption($optionName,$optionValue); + Console::writeInfo("config option ".$optionName." updated...", false, true); + } else { + Console::writeWarning("config option ".$optionName." not updated...", false, true); + } + } } From 9a9d381d3d24b97b26bd602e0394848525ee8996 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:47:01 -0500 Subject: [PATCH 147/436] getting the correct adapter for OS X Yosemite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This scares me a bit that’s the adapter changed. Need to make more I guess. --- src/PatternLab/Zippy/UnpackAdapter.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Zippy/UnpackAdapter.php b/src/PatternLab/Zippy/UnpackAdapter.php index b6230ddc..fac2358d 100644 --- a/src/PatternLab/Zippy/UnpackAdapter.php +++ b/src/PatternLab/Zippy/UnpackAdapter.php @@ -13,16 +13,16 @@ namespace PatternLab\Zippy; -use \Alchemy\Zippy\Adapter\GNUTar\TarGNUTarAdapter; +use \Alchemy\Zippy\Adapter\BSDTar\TarGzBSDTarAdapter; -class UnpackAdapter extends TarGNUTarAdapter { +class UnpackAdapter extends TarGzBSDTarAdapter { protected function getExtractOptions() { - return array('--overwrite-dir', '--overwrite', '--strip-components=1'); + return array('--strip-components=1'); } protected function getExtractMembersOptions() { - return array('--overwrite-dir', '--overwrite', '--strip-components=1'); + return array('--strip-components=1'); } -} \ No newline at end of file +} From c925360e6aec77c4d4fd105c8acab6709ed0e6ed Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:47:54 -0500 Subject: [PATCH 148/436] directly instantiating filesystem in methods that need it --- src/PatternLab/InstallerUtil.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 60e84d90..8f3a1872 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -21,8 +21,6 @@ class InstallerUtil { - protected static $fs; - /** * Move the component files from the package to their location in the patternlab-components dir * @param {String/Array} the items to create a fileList for @@ -58,8 +56,6 @@ protected static function init() { $baseDir = __DIR__."/../../../../../"; Config::init($baseDir,false); - // load the file system function - self::$fs = new Filesystem(); } /** @@ -73,9 +69,11 @@ protected static function init() { */ protected static function moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase) { + $fs = new Filesystem(); + // make sure the destination base exists if (!is_dir($destinationBase)) { - self::$fs->mkdir($destinationBase); + $fs->mkdir($destinationBase); } // clean any * or / on the end of $destination @@ -336,7 +334,9 @@ protected static function parseFileList($packageName,$sourceBase,$destinationBas */ protected static function pathExists($packageName,$path) { - if (self::$fs->exists($path)) { + $fs = new Filesystem; + + if ($fs->exists($path)) { // set-up a human readable prompt $humanReadablePath = str_replace(Config::getOption("baseDir"), "./", $path); From c359189fef96c6d0a10dfa215e9735c5e678ce2f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:48:13 -0500 Subject: [PATCH 149/436] copy changes --- src/PatternLab/InstallerUtil.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 8f3a1872..523f48c8 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -366,15 +366,15 @@ protected static function pathExists($packageName,$path) { if ($prompt) { // prompt for input using the supplied query - $prompt = "the path ".$humanReadablePath." already exists. merge and possibly overwrite it the with contents from the ".$packageName." package?"; - $options = "Y/n"; + $prompt = "the path ".$humanReadablePath." already exists. merge or replace with the contents of ".$packageName." package?"; + $options = "M/r"; $input = Console::promptInput($prompt,$options); - if ($input == "y") { - Console::writeTag("ok","contents of ".$humanReadablePath." are being replaced and may be overwritten...", false, true); + if ($input == "m") { + Console::writeTag("ok","contents of ".$humanReadablePath." have been merged with the package's content...", false, true); return false; } else { - Console::writeWarning("contents of ".$humanReadablePath." weren't overwritten. some parts of the ".$packageName." package may be missing...", false, true); + Console::writeWarning("contents of ".$humanReadablePath." have been replaced by the package's content...", false, true); return true; } From dd76d07fd0a8305e3b668e0d7ef935961b36d01e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:48:35 -0500 Subject: [PATCH 150/436] smarter handling of merge vs replace --- src/PatternLab/InstallerUtil.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 523f48c8..18ab732a 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -88,28 +88,28 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas // foo/s.html ~ path/k.html -> mirror {srcroot}/foo/s.html to {destroot}/path/k.html if (($source == "*") && ($destination == "*")) { - if (!self::pathExists($packageName,$destinationBase."/")) { - self::$fs->mirror($sourceBase,$destinationBase."/"); - } + $result = self::pathExists($packageName, $destinationBase."/"); + $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); + $fs->mirror($sourceBase, $destinationBase."/", null, $options); } else if ($source == "*") { - if (!self::pathExists($packageName,$destinationBase."/".$destination)) { - self::$fs->mirror($sourceBase,$destinationBase."/".$destination); - } + $result = self::pathExists($packageName, $destinationBase."/".$destination); + $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); + $fs->mirror($sourceBase, $destinationBase."/".$destination, null, $options); } else if ($source[strlen($source)-1] == "*") { - $source = rtrim($source,"/*"); - if (!self::pathExists($packageName,$destinationBase."/".$destination)) { - self::$fs->mirror($sourceBase.$source,$destinationBase."/".$destination); - } + $source = rtrim($source,"/*"); + $result = self::pathExists($packageName, $destinationBase."/".$destination); + $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); + $fs->mirror($sourceBase.$source, $destinationBase."/".$destination, null, $options); } else { $pathInfo = explode("/",$destination); $file = array_pop($pathInfo); $destinationDir = implode("/",$pathInfo); - if (!self::$fs->exists($destinationBase."/".$destinationDir)) { - self::$fs->mkdir($destinationBase."/".$destinationDir); - } - if (!self::pathExists($packageName,$destinationBase."/".$destination)) { - self::$fs->copy($sourceBase.$source,$destinationBase."/".$destination,true); + if (!$fs->exists($destinationBase."/".$destinationDir)) { + $fs->mkdir($destinationBase."/".$destinationDir); } + $result = self::pathExists($packageName, $destinationBase."/".$destination); + $override = ($result) ? true : false; + $fs->copy($sourceBase.$source, $destinationBase."/".$destination, $override); } } From 9a3fe20266cc176548c0ffa0c3da7930fcfc0e75 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:48:47 -0500 Subject: [PATCH 151/436] syntax fix --- src/PatternLab/Fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 83cbe177..723159e3 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -59,7 +59,7 @@ public function fetchStarterKit($starterkit = "") { $sourceDir = Config::getOption("sourceDir"); $tempDir = sys_get_temp_dir(); $tempDirSK = $tempDir.DIRECTORY_SEPARATOR."pl-sk-archive"; - $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist" + $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist"; $tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR."composer.json"; $fs = new Filesystem(); From 84b0ae6a6a4637aec0a05d2b644a540aca3a02f1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:49:42 -0500 Subject: [PATCH 152/436] running empty dir check only if composer.json doesn't exist --- src/PatternLab/Fetch.php | 46 +++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 723159e3..91007f1c 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -84,30 +84,6 @@ public function fetchStarterKit($starterkit = "") { Console::writeInfo("installing the starterkit..."); - // see if the source directory is empty - $emptyDir = true; - if (is_dir($sourceDir)) { - $objects = new \DirectoryIterator($sourceDir); - foreach ($objects as $object) { - if (!$object->isDot() && ($object->getFilename() != "README") && ($object->getFilename() != ".DS_Store")) { - $emptyDir = false; - } - } - } - - // if source directory isn't empty ask if it's ok to nuke what's there - if (!$emptyDir) { - - $prompt = "a starterkit is already installed. merge or replace?"; - $options = "M/r"; - $input = Console::promptInput($prompt,$options); - - if ($answer == "r") { - Console::writeWarning("deleting the old files before installing the new starterkit..."); - $fs->remove($checkDir); - } - - } // make sure the temp dir exists before copying into it if (!is_dir($tempDirSK)) { @@ -132,6 +108,28 @@ public function fetchStarterKit($starterkit = "") { InstallerUtil::parseComposerExtraList($tempComposerJSON, $starterkit, $tempDirDist) } else { $fs->mirror($tempDirDist, $sourceDir); + + // see if the source directory is empty + $emptyDir = true; + if (is_dir($sourceDir)) { + $objects = new \DirectoryIterator($sourceDir); + foreach ($objects as $object) { + if (!$object->isDot() && ($object->getFilename() != "README") && ($object->getFilename() != ".DS_Store")) { + $emptyDir = false; + } + } + } + + // if source directory isn't empty ask if it's ok to nuke what's there + if (!$emptyDir) { + + $prompt = "a starterkit is already installed. merge or replace?"; + $options = "M/r"; + $input = Console::promptInput($prompt,$options); + $options = ($input == "r") ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); + + } + } // remove the temp files From 6371a5250eafec115bc6c143d446429bf0a5ca7b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:49:58 -0500 Subject: [PATCH 153/436] copy changes --- src/PatternLab/Fetch.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 91007f1c..e83884b5 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -82,8 +82,7 @@ public function fetchStarterKit($starterkit = "") { $tempFile = tempnam($tempDir, "pl-sk-archive.tar.gz"); file_put_contents($tempFile, $package); - Console::writeInfo("installing the starterkit..."); - + Console::writeInfo("finished downloading the starterkit..."); // make sure the temp dir exists before copying into it if (!is_dir($tempDirSK)) { From a0d5552d076f0e2b4612c62163c24a05229a7b9b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:50:28 -0500 Subject: [PATCH 154/436] adding copy --- src/PatternLab/Fetch.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index e83884b5..eed02d9d 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -106,7 +106,6 @@ public function fetchStarterKit($starterkit = "") { $tempComposerJSON = json_decode(file_get_contents($tempComposerFile), true); InstallerUtil::parseComposerExtraList($tempComposerJSON, $starterkit, $tempDirDist) } else { - $fs->mirror($tempDirDist, $sourceDir); // see if the source directory is empty $emptyDir = true; @@ -129,6 +128,10 @@ public function fetchStarterKit($starterkit = "") { } + Console::writeInfo("installing the starterkit files..."); + $fs->mirror($tempDirDist, $sourceDir, null, $options); + Console::writeInfo("starterkit files have been installed..."); + } // remove the temp files From 6f580fbd92dc11f9693668453f2c901d72f5549f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:50:52 -0500 Subject: [PATCH 155/436] making sure i pass in the patternlab properties --- src/PatternLab/Fetch.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index eed02d9d..c31ee482 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -103,8 +103,16 @@ public function fetchStarterKit($starterkit = "") { // check for composer.json. if it exists use it for determining things. otherwise just mirror dist/ to source/ if (file_exists($tempComposerFile)) { + $tempComposerJSON = json_decode(file_get_contents($tempComposerFile), true); - InstallerUtil::parseComposerExtraList($tempComposerJSON, $starterkit, $tempDirDist) + if (isset($tempComposerJSON["extra"]) && isset($tempComposerJSON["extra"]["patternlab"])) { + Console::writeInfo("installing the starterkit..."); + InstallerUtil::parseComposerExtraList($tempComposerJSON["extra"]["patternlab"], $starterkit, $tempDirDist); + Console::writeInfo("installed the starterkit..."); + } else { + Console::writeError("the starterkit's composer.json file didn't have a valid format. missing patternlab directives..."); + } + } else { // see if the source directory is empty From 4738bea8d90750779bc8dbfdbd0251a930c73a9e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:51:04 -0500 Subject: [PATCH 156/436] slimmed down the zippy call --- src/PatternLab/Fetch.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index c31ee482..0587cea6 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -90,11 +90,9 @@ public function fetchStarterKit($starterkit = "") { } // extract, if the zip is supposed to be unpacked do that (e.g. stripdir) - $zippy = Zippy::load(); + $zippy = Zippy::load(); $zippy->addStrategy(new UnpackFileStrategy()); - $zipAdapter = $zippy->getAdapterFor('tar.gz'); - $archiveZip = $zipAdapter->open($tempFile); - $archiveZip = $archiveZip->extract($tempDirSK); + $zippy->getAdapterFor('tar.gz')->open($tempFile)->extract($tempDirSK); // thrown an error if temp/dist/ doesn't exist if (!is_dir($tempDirDist)) { From 4a95c6e60d0edb1155e24d1fd5b0e6146c422eb8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:51:26 -0500 Subject: [PATCH 157/436] removing the starterkit option from the fetch command --- src/PatternLab/Console/Commands/FetchCommand.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/PatternLab/Console/Commands/FetchCommand.php b/src/PatternLab/Console/Commands/FetchCommand.php index 30ccdb8f..6ede1e0b 100644 --- a/src/PatternLab/Console/Commands/FetchCommand.php +++ b/src/PatternLab/Console/Commands/FetchCommand.php @@ -26,15 +26,13 @@ public function __construct() { Console::setCommand($this->command,"Fetch a package or StarterKit","The fetch command downloads packages and StarterKits.","f"); Console::setCommandOption($this->command,"package:","Fetch a package from Packagist.","To fetch a package from Packagist:","p:",""); - Console::setCommandOption($this->command,"starterkit:","Fetch a StarterKit from GitHub.","To fetch a StarterKit from GitHub:","s:",""); } public function run() { // find the value given to the command - $package = Console::findCommandValue("p|package"); - $starterkit = Console::findCommandValue("s|starterkit"); + $package = Console::findCommandOptionValue("p|package"); if ($package) { @@ -54,12 +52,6 @@ public function run() { $f = new Fetch(); $f->fetchPackage($package); - } else if ($starterkit) { - - // download the starterkit - $f = new Fetch(); - $f->fetchStarterKit($starterkit); - } else { Console::writeHelpCommand($this->command); From 74e0ae287dbc7d36a6af1fcefd9a9d4fd7202af3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 28 Feb 2015 16:51:46 -0500 Subject: [PATCH 158/436] renaming the fetch option to install to avoid conflicts with the reg command --- src/PatternLab/Console/Commands/StarterKitCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Console/Commands/StarterKitCommand.php b/src/PatternLab/Console/Commands/StarterKitCommand.php index 9e9c23fc..a14f763b 100644 --- a/src/PatternLab/Console/Commands/StarterKitCommand.php +++ b/src/PatternLab/Console/Commands/StarterKitCommand.php @@ -26,15 +26,15 @@ public function __construct() { Console::setCommand($this->command,"Initialize or fetch a specific StarterKit","The StarterKit command downloads StarterKits.","k"); Console::setCommandOption($this->command,"init","Initialize with a blank StarterKit based on the active PatternEngine.","To initialize your project with a base StarterKit:","i"); - Console::setCommandOption($this->command,"fetch:","Fetch a specific StarterKit from GitHub.","To fetch a StarterKit from GitHub:","f:",""); + Console::setCommandOption($this->command,"install:","Fetch a specific StarterKit from GitHub.","To fetch a StarterKit from GitHub:","j:",""); } public function run() { // find the value given to the command - $init = Console::findCommandValue("i|init"); - $starterkit = Console::findCommandValue("f|fetch"); + $init = Console::findCommandOption("i|init"); + $starterkit = Console::findCommandOptionValue("f|install"); if ($init) { $patternEngine = Config::getOption("patternExtension"); From 9bf46dbe6d444ba9292ea39cbc8910f3eccb546b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 10:48:03 -0500 Subject: [PATCH 159/436] adding a human readable path method --- src/PatternLab/Console.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index b002137c..c8da4588 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -428,6 +428,16 @@ public static function getSpacer($lengthLong,$itemLongLength) { return $spacer; } + /** + * Make a path human readable by dropping the base dir + * @param {String} the path to clean + * + * @return {String} cleaned up path + */ + public static function getHumanReadablePath($path) { + return str_replace(Config::getOption("baseDir"), "./", $path); + } + /** * Modify a line to include the given tag by default * @param {String} the content to be written out From dbe1d67a80b3e314cd8659b32141948ddc037244 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 10:48:13 -0500 Subject: [PATCH 160/436] standardizing with a new line --- src/PatternLab/Zippy/UnpackFileStrategy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Zippy/UnpackFileStrategy.php b/src/PatternLab/Zippy/UnpackFileStrategy.php index 9a479bd6..3267f0fc 100644 --- a/src/PatternLab/Zippy/UnpackFileStrategy.php +++ b/src/PatternLab/Zippy/UnpackFileStrategy.php @@ -31,4 +31,4 @@ public function getFileExtension() { return 'tar.gz'; } -} \ No newline at end of file +} From f90d0b3ea02a28e46307bb3843076ab4ff296766 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 18:58:49 -0500 Subject: [PATCH 161/436] making the package requirements looser --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index b8670222..0dda9a7f 100644 --- a/composer.json +++ b/composer.json @@ -31,12 +31,12 @@ "prefer-stable": true, "require": { "php": ">=5.3.6", - "michelf/php-markdown": "1.4", - "symfony/yaml": "2.4.4", - "seld/jsonlint": "1.1.2", - "symfony/event-dispatcher": "v2.5.0", - "symfony/filesystem": "v2.5.0", - "symfony/finder": "v2.5.3", + "michelf/php-markdown": "~1.4", + "symfony/yaml": "~2.4", + "seld/jsonlint": "~1.1", + "symfony/event-dispatcher": "~2.5", + "symfony/filesystem": "~2.5", + "symfony/finder": "~2.5", "kevinlebrun/colors.php": "0.*", "pattern-lab/unified-asset-installer": "dev-dev", "alchemy/zippy": "~0.2.1" From 0c2c1237de58995de030addc4e86f0bfc2022768 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 20:57:31 -0500 Subject: [PATCH 162/436] adding license and simple README --- LICENSE | 20 ++++++++++++++++++++ README.md | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..dc8c7c4b --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2015 Brad Frost, http://bradfrostweb.com & Dave Olsen, http://dmolsen.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..44657470 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Pattern Lab Core + +This repository contains the core functionality for Pattern Lab. Pattern Lab Core is designed to be included as a dependency within Editions. \ No newline at end of file From d3569c8ae913398d342dab4f2b026fdd715f20c8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 22:20:00 -0500 Subject: [PATCH 163/436] removing dev dependencies --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0dda9a7f..0c5e9cfa 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "PatternLab": "src/" } }, - "minimum-stability": "dev", "prefer-stable": true, "require": { "php": ">=5.3.6", @@ -38,7 +37,7 @@ "symfony/filesystem": "~2.5", "symfony/finder": "~2.5", "kevinlebrun/colors.php": "0.*", - "pattern-lab/unified-asset-installer": "dev-dev", + "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "~0.2.1" } } From 59418b4c8b9f0976c36898259b6db25c704dc71f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 23:27:14 -0500 Subject: [PATCH 164/436] fixing space --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 0051e6e1..6cc6cfb3 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -318,7 +318,7 @@ public static function updateConfigOption($optionName,$optionValue) { $prompt = "update the config option ".$optionName." with the value ".$newOptionValue."?"; $options = "Y/n"; $input = Console::promptInput($prompt,$options); - + if ($input == "y") { self::writeUpdateConfigOption($optionName,$optionValue); Console::writeInfo("config option ".$optionName." updated...", false, true); From 8f4daf93b782c9f6057d71b71314089300e9d13d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 1 Mar 2015 23:27:33 -0500 Subject: [PATCH 165/436] making sure var is set before inspecting --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 6cc6cfb3..e5217250 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -373,7 +373,7 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); } - if (is_array($options[$optionName])) { + if (isset($options[$optionName]) && is_array($options[$optionName])) { $optionValue = is_array($optionValue) ? $optionValue : array($optionValue); $options[$optionName] = array_merge($options[$optionName], $optionValue); } else { From 763feebb0c5953c81a48dbda4243d0c0348f6142 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 08:57:11 -0500 Subject: [PATCH 166/436] updating the colors dependency to match the others --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0dda9a7f..9d174888 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "symfony/event-dispatcher": "~2.5", "symfony/filesystem": "~2.5", "symfony/finder": "~2.5", - "kevinlebrun/colors.php": "0.*", + "kevinlebrun/colors.php": "~0.4", "pattern-lab/unified-asset-installer": "dev-dev", "alchemy/zippy": "~0.2.1" } From 91a0e43abd11896b814b9dea5cd658d94380e8b4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 09:05:14 -0500 Subject: [PATCH 167/436] grabbing a stable release of UAI --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7468cc8c..c30123bc 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "symfony/filesystem": "~2.5", "symfony/finder": "~2.5", "kevinlebrun/colors.php": "~0.4", - "pattern-lab/unified-asset-installer": "dev-dev", + "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "~0.2.1" } } From 247ac91b5ba678fe42aec19b7475c6f5c0f9a453 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 15:52:01 -0500 Subject: [PATCH 168/436] adding a min stability --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index c30123bc..fb6089dd 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "PatternLab": "src/" } }, + "minimum-stability": "dev", "prefer-stable": true, "require": { "php": ">=5.3.6", From bc588053e1d7fdd7d9bf5aef0bf852b8888e2bf1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 19:24:07 -0500 Subject: [PATCH 169/436] going with dev branch for UAI to match dev composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fb6089dd..9d174888 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "symfony/filesystem": "~2.5", "symfony/finder": "~2.5", "kevinlebrun/colors.php": "~0.4", - "pattern-lab/unified-asset-installer": "~0.5", + "pattern-lab/unified-asset-installer": "dev-dev", "alchemy/zippy": "~0.2.1" } } From bf536533990b779e9c3423e5e2368f4af7ff4112 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 19:40:50 -0500 Subject: [PATCH 170/436] back to a tag-based dependency --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9d174888..fb6089dd 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "symfony/filesystem": "~2.5", "symfony/finder": "~2.5", "kevinlebrun/colors.php": "~0.4", - "pattern-lab/unified-asset-installer": "dev-dev", + "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "~0.2.1" } } From 56765d8a327f2f60b83730eed82637c08d2e1e0f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 21:42:57 -0500 Subject: [PATCH 171/436] switching back yet again to dev-dev for UAI --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fb6089dd..9d174888 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "symfony/filesystem": "~2.5", "symfony/finder": "~2.5", "kevinlebrun/colors.php": "~0.4", - "pattern-lab/unified-asset-installer": "~0.5", + "pattern-lab/unified-asset-installer": "dev-dev", "alchemy/zippy": "~0.2.1" } } From ea7b0532da8384854b860ec397dc42581bf12530 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 2 Mar 2015 22:15:12 -0500 Subject: [PATCH 172/436] going to stars --- composer.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 9d174888..dbc2f835 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ "prefer-stable": true, "require": { "php": ">=5.3.6", - "michelf/php-markdown": "~1.4", - "symfony/yaml": "~2.4", - "seld/jsonlint": "~1.1", - "symfony/event-dispatcher": "~2.5", - "symfony/filesystem": "~2.5", - "symfony/finder": "~2.5", - "kevinlebrun/colors.php": "~0.4", - "pattern-lab/unified-asset-installer": "dev-dev", - "alchemy/zippy": "~0.2.1" + "michelf/php-markdown": "1.*", + "symfony/yaml": "2.*", + "seld/jsonlint": "1.*", + "symfony/event-dispatcher": "2.*", + "symfony/filesystem": "2.*", + "symfony/finder": "2.*", + "kevinlebrun/colors.php": "0.*", + "pattern-lab/unified-asset-installer": "0.*", + "alchemy/zippy": "0.*" } } From 02b4a42bd9d701873a4338464ee0ec4f62546052 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 11:03:56 -0500 Subject: [PATCH 173/436] updating the version --- config/config.yml.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml.default b/config/config.yml.default index 9e3122ca..01c0bd48 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -1,7 +1,7 @@ ## Configuration Options for Pattern Lab # pattern lab version -v: "0.7.12" +v: "2.0.0-DP1" # what to do when included config var conflicts, q for question, a for always override, n for never override overrideConfig: "q" From 3b7f54b6d5b5ef6de4ca7cc5dca4f91574bda242 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 14:56:34 -0500 Subject: [PATCH 174/436] picking a better command to run this against --- src/PatternLab/InstallerUtil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 18ab732a..cf75c374 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -416,10 +416,10 @@ public static function postPackageUpdate($event) { } /** - * Make sure certain things are set-up before running composer's install + * Make sure certain things are set-up before running the installation of dependencies for a project * @param {Object} a script event object from composer */ - public static function preInstallCmd($event) { + public static function postRootPackageInstall($event) { // run the console and config inits self::init(); From 779bc967653ce8d6b49cf27914809d746ed9065e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 14:59:06 -0500 Subject: [PATCH 175/436] adding a post-create-project-cmd --- src/PatternLab/InstallerUtil.php | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index cf75c374..c526f074 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -439,6 +439,44 @@ public static function postRootPackageInstall($event) { } + /** + * Ask questions after the create package is done + * @param {Object} a script event object from composer + */ + public static function postCreateProjectCmd($event) { + + print $event->getOperation()->getPackage()->getName(); + + // run the console and config inits + /*self::init(); + + print_r($event) + if (Config::getOption("patternExtension")) { + + } + $input = Console::promptInput("Install the base StarterKit for Twig?","(Y/n)"); + + if ($input == "y") { + $patternEngine = Config::getOption("patternExtension"); + $starterkit = "pattern-lab/starterkit-".$patternEngine."-base"; + } + + if ($starterkit) { + + // download the starterkit + $f = new Fetch(); + $f->fetchStarterKit($starterkit); + + } else if ($input == "n") { + + } else { + Console::writeWarning("i didn't understand that input. so you can just set that up after the install finishes"); + } + */ + + } + + /** * Make sure pattern engines and listeners are removed on uninstall * @param {Object} a script event object from composer From 24dd28f2ccfb3ce97d3af70bbc8adf9608e5aac1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 15:17:46 -0500 Subject: [PATCH 176/436] renaming and move the preinstallcmd code --- src/PatternLab/InstallerUtil.php | 47 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index c526f074..68ed9fbe 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -415,30 +415,6 @@ public static function postPackageUpdate($event) { } - /** - * Make sure certain things are set-up before running the installation of dependencies for a project - * @param {Object} a script event object from composer - */ - public static function postRootPackageInstall($event) { - - // run the console and config inits - self::init(); - - // default vars - $sourceDir = Config::getOption("sourceDir"); - $packagesDir = Config::getOption("packagesDir"); - - // check directories - if (!is_dir($sourceDir)) { - mkdir($sourceDir); - } - - if (!is_dir($packagesDir)) { - mkdir($packagesDir); - } - - } - /** * Ask questions after the create package is done * @param {Object} a script event object from composer @@ -476,6 +452,29 @@ public static function postCreateProjectCmd($event) { } + /** + * Make sure certain things are set-up before running the installation of a package + * @param {Object} a script event object from composer + */ + public static function preInstallCmd($event) { + + // run the console and config inits + self::init(); + + // default vars + $sourceDir = Config::getOption("sourceDir"); + $packagesDir = Config::getOption("packagesDir"); + + // check directories + if (!is_dir($sourceDir)) { + mkdir($sourceDir); + } + + if (!is_dir($packagesDir)) { + mkdir($packagesDir); + } + + } /** * Make sure pattern engines and listeners are removed on uninstall From 8e4284fb9cce38e175325427767169941636f5eb Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 15:35:23 -0500 Subject: [PATCH 177/436] updating the path to the config file --- src/PatternLab/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index e5217250..b46017fa 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -26,7 +26,7 @@ class Config { protected static $userConfigDirClean = "config"; protected static $userConfigDirDash = "_config"; protected static $userConfigPath = ""; - protected static $plConfigPath = "../../config/config.yml.default"; + protected static $plConfigPath = "config/config.yml.default"; protected static $dirAdded = false; /** @@ -105,7 +105,7 @@ public static function init($baseDir = "", $verbose = true) { self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; - self::$plConfigPath = __DIR__.DIRECTORY_SEPARATOR.self::$plConfigPath; + self::$plConfigPath = self::$options["baseDir"].self::$plConfigPath; self::$dirAdded = true; // just in case the config directory doesn't exist at all From 746d344af8d09e4666d66499bccb3f475b594a1e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 15:54:29 -0500 Subject: [PATCH 178/436] updating the path to the default config --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index b46017fa..63f1a40c 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -105,7 +105,7 @@ public static function init($baseDir = "", $verbose = true) { self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; - self::$plConfigPath = self::$options["baseDir"].self::$plConfigPath; + self::$plConfigPath = self::$options["baseDir"]."/vendor/pattern-lab/core/".self::$plConfigPath; self::$dirAdded = true; // just in case the config directory doesn't exist at all From af5029f72eee51b5ad713a15a87cfc29ce7da7ae Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 15:57:59 -0500 Subject: [PATCH 179/436] better method? --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 68ed9fbe..2bf6ed96 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -421,7 +421,7 @@ public static function postPackageUpdate($event) { */ public static function postCreateProjectCmd($event) { - print $event->getOperation()->getPackage()->getName(); + print $event->getComposer()->getPackage()->getName(); // run the console and config inits /*self::init(); From d0024d9aca5e41f54afe895c9c1703c434719e54 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 17:29:06 -0500 Subject: [PATCH 180/436] returning a result --- src/PatternLab/Fetch.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 0587cea6..50e4fef3 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -147,6 +147,8 @@ public function fetchStarterKit($starterkit = "") { Console::writeInfo("the starterkit installation is complete..."); + return true; + } /** From f213f0d129a6472686fa0ffcbd5b264a6da845b9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 17:29:43 -0500 Subject: [PATCH 181/436] adding a starterkit suggestion handler --- src/PatternLab/InstallerUtil.php | 71 +++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 2bf6ed96..e36fee43 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -421,34 +421,59 @@ public static function postPackageUpdate($event) { */ public static function postCreateProjectCmd($event) { - print $event->getComposer()->getPackage()->getName(); + // see if there is an extra component + $extra = $event->getComposer()->getPackage()->getExtra(); - // run the console and config inits - /*self::init(); - - print_r($event) - if (Config::getOption("patternExtension")) { + if (isset($extra["patternlab"])) { - } - $input = Console::promptInput("Install the base StarterKit for Twig?","(Y/n)"); - - if ($input == "y") { - $patternEngine = Config::getOption("patternExtension"); - $starterkit = "pattern-lab/starterkit-".$patternEngine."-base"; - } - - if ($starterkit) { - - // download the starterkit - $f = new Fetch(); - $f->fetchStarterKit($starterkit); + self::init(); + Console::writeLine(""); - } else if ($input == "n") { + // see if we have any starterkits to suggest + if (isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) { + + $suggestions = $extra["patternlab"]["starterKitSuggestions"]; + + // suggest starterkits + Console::writeLine("suggested StarterKits that work with this edition:"); + foreach ($suggestions as $i => $suggestion) { + + // write each suggestion + Console::writeLine($i.": ".$suggestion, true); + + } + + // prompt for input on the suggestions + $prompt = "choose an option or hit return to skip:"; + $options = "(ex. 1)"; + $input = Console::promptInput($prompt,$options); + + if (isset($suggestions[$input])) { + + Console::writeLine(""); + $f = new Fetch(); + $result = $f->fetchStarterKit($suggestions[$input]); + + if ($result) { + + Console::writeLine(""); + $g = new Generator(); + $g->generate(array("foo" => "bar")); + + Console::writeLine(""); + Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); + + } + + } else { + + Console::writeWarning("you will need to install a StarterKit before using Pattern Lab..."); + + } + + } - } else { - Console::writeWarning("i didn't understand that input. so you can just set that up after the install finishes"); } - */ } From 1c988601b5a419521dbd83a26728c7c2ab9a1fa7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 17:39:29 -0500 Subject: [PATCH 182/436] checking current option value --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 63f1a40c..ec97c79e 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -315,7 +315,7 @@ public static function updateConfigOption($optionName,$optionValue) { if ($currentOptionValue != $newOptionValue) { // prompt for input - $prompt = "update the config option ".$optionName." with the value ".$newOptionValue."?"; + $prompt = "update the config option ".$optionName." (".$currentOptionValue.") with the value ".$newOptionValue."?"; $options = "Y/n"; $input = Console::promptInput($prompt,$options); From d50a08e84b70bd8044f6b7cf8538ca31e4afb047 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 17:52:01 -0500 Subject: [PATCH 183/436] making sure the assets styleguidekit doesn't update PL config --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index e36fee43..f38197bb 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -575,7 +575,7 @@ protected static function runTasks($event,$type) { self::scanForPatternEngineRule($pathBase); } else if ($type == "patternlab-starterkit") { Config::updateConfigOption("starterKit",$name); - } else if ($type == "patternlab-styleguidekit") { + } else if (($type == "patternlab-styleguidekit") && (strpos($type,"-assets-") === false)) { Config::updateConfigOption("styleguideKit",$name); } From e5083cccbbd961142fcaa96dc0d0e5fe75ba604e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 18:00:31 -0500 Subject: [PATCH 184/436] cleaning up the suggestion --- src/PatternLab/InstallerUtil.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index f38197bb..0733b759 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -439,7 +439,8 @@ public static function postCreateProjectCmd($event) { foreach ($suggestions as $i => $suggestion) { // write each suggestion - Console::writeLine($i.": ".$suggestion, true); + $num = $i + 1; + Console::writeLine($num.": ".$suggestion, true); } @@ -447,12 +448,13 @@ public static function postCreateProjectCmd($event) { $prompt = "choose an option or hit return to skip:"; $options = "(ex. 1)"; $input = Console::promptInput($prompt,$options); + $result = (int)$input - 1; - if (isset($suggestions[$input])) { + if (isset($suggestions[$result])) { Console::writeLine(""); $f = new Fetch(); - $result = $f->fetchStarterKit($suggestions[$input]); + $result = $f->fetchStarterKit($suggestions[$result]); if ($result) { From dcf5c66e140f662e68de48b58d5d23f6b3f45540 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 18:13:39 -0500 Subject: [PATCH 185/436] making sure to always force copy of dist --- src/PatternLab/Fetch.php | 70 ++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 50e4fef3..bf698d24 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -62,8 +62,6 @@ public function fetchStarterKit($starterkit = "") { $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist"; $tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR."composer.json"; - $fs = new Filesystem(); - // figure out the options for the GH path list($org,$repo,$tag) = $this->getPackageInfo($starterkit); @@ -103,40 +101,19 @@ public function fetchStarterKit($starterkit = "") { if (file_exists($tempComposerFile)) { $tempComposerJSON = json_decode(file_get_contents($tempComposerFile), true); + + // see if it has a patternlab section that might define the files to move if (isset($tempComposerJSON["extra"]) && isset($tempComposerJSON["extra"]["patternlab"])) { Console::writeInfo("installing the starterkit..."); InstallerUtil::parseComposerExtraList($tempComposerJSON["extra"]["patternlab"], $starterkit, $tempDirDist); Console::writeInfo("installed the starterkit..."); } else { - Console::writeError("the starterkit's composer.json file didn't have a valid format. missing patternlab directives..."); + $this->mirrorDist($sourceDir, $tempDirDist); } } else { - // see if the source directory is empty - $emptyDir = true; - if (is_dir($sourceDir)) { - $objects = new \DirectoryIterator($sourceDir); - foreach ($objects as $object) { - if (!$object->isDot() && ($object->getFilename() != "README") && ($object->getFilename() != ".DS_Store")) { - $emptyDir = false; - } - } - } - - // if source directory isn't empty ask if it's ok to nuke what's there - if (!$emptyDir) { - - $prompt = "a starterkit is already installed. merge or replace?"; - $options = "M/r"; - $input = Console::promptInput($prompt,$options); - $options = ($input == "r") ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); - - } - - Console::writeInfo("installing the starterkit files..."); - $fs->mirror($tempDirDist, $sourceDir, null, $options); - Console::writeInfo("starterkit files have been installed..."); + $this->mirrorDist($sourceDir, $tempDirDist); } @@ -177,4 +154,43 @@ protected function getPackageInfo($package) { } + /** + * Force mirror the dist/ folder to source/ + * @param {String} path to the source directory + * @param {String} path to the temp dist directory + */ + protected function mirrorDist($sourceDir, $tempDirDist) { + + // set default vars + $fsOptions = array(); + $emptyDir = true; + + // see if the source directory is empty + if (is_dir($sourceDir)) { + $objects = new \DirectoryIterator($sourceDir); + foreach ($objects as $object) { + if (!$object->isDot() && ($object->getFilename() != "README") && ($object->getFilename() != ".DS_Store")) { + $emptyDir = false; + } + } + } + + // if source directory isn't empty ask if it's ok to nuke what's there + if (!$emptyDir) { + + $prompt = "a starterkit is already installed. merge the new files with it or replace it?"; + $options = "M/r"; + $input = Console::promptInput($prompt,$options); + $fsOptions = ($input == "r") ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); + + } + + // mirror dist to source + Console::writeInfo("installing the starterkit files..."); + $fs = new Filesystem(); + $fs->mirror($tempDirDist, $sourceDir, null, $options); + Console::writeInfo("starterkit files have been installed..."); + + } + } From e3be5639939e85b7d88fd3a20f73dae3e86cf2c7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 18:13:58 -0500 Subject: [PATCH 186/436] cleaning up the copy for suggestion kits --- src/PatternLab/InstallerUtil.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 0733b759..f0a72bff 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -435,7 +435,7 @@ public static function postCreateProjectCmd($event) { $suggestions = $extra["patternlab"]["starterKitSuggestions"]; // suggest starterkits - Console::writeLine("suggested StarterKits that work with this edition:"); + Console::writeInfo("suggested starterkits that work with this edition:", false, true); foreach ($suggestions as $i => $suggestion) { // write each suggestion @@ -445,6 +445,7 @@ public static function postCreateProjectCmd($event) { } // prompt for input on the suggestions + Console::writeLine(""); $prompt = "choose an option or hit return to skip:"; $options = "(ex. 1)"; $input = Console::promptInput($prompt,$options); From c694d7245f3d1aef3719b2c2efd6a277baed36fa Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 19:16:16 -0500 Subject: [PATCH 187/436] make sure the user is running PHP 5.4.0 to use the built-in server --- .../Console/Commands/ServerCommand.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index c60183d4..4582c5b5 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -29,12 +29,21 @@ public function __construct() { public function run() { - // set-up defaults - $publicDir = Config::getOption("publicDir"); - $coreDir = Config::getOption("coreDir"); - - Console::writeInfo("server started on localhost:8080. use ctrl+c to exit..."); - passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S localhost:8080 ".$coreDir."/server/router.php"); + if (version_compare(phpversion(), '5.4.0', '<')) { + + Console::writeWarning("you must have PHP 5.4.0 or greater to use this feature. you are using PHP ".phpversion()."..."); + + } else { + + // set-up defaults + $publicDir = Config::getOption("publicDir"); + $coreDir = Config::getOption("coreDir"); + + // start-up the server with the router + Console::writeInfo("server started on localhost:8080. use ctrl+c to exit..."); + passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S localhost:8080 ".$coreDir."/server/router.php"); + + } } From 99c7f9946b123843857cd0ae65b8217b4330bf13 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 20:15:10 -0500 Subject: [PATCH 188/436] removing an unnecessary space --- src/PatternLab/Builder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 8099034a..b4dad348 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -222,7 +222,6 @@ protected function generatePatterns($options = array()) { $patternSourceDir = Config::getOption("patternSourceDir"); $patternExtension = Config::getOption("patternExtension"); - // make sure the export dir exists if ($exportFiles && !is_dir($exportDir)) { mkdir($exportDir); From 0f1a3f1ee75fc2f657a739a1f8dabeef32fc2677 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 20:16:11 -0500 Subject: [PATCH 189/436] adding support for a separate raw pattern helper --- src/PatternLab/PatternData.php | 12 ++++ .../PatternData/Helpers/PatternCodeHelper.php | 25 -------- .../PatternData/Helpers/RawPatternHelper.php | 63 +++++++++++++++++++ 3 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 src/PatternLab/PatternData/Helpers/RawPatternHelper.php diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index b9a80ab0..0db200ef 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -23,6 +23,7 @@ use \PatternLab\PatternData\Helpers\LineageHelper; use \PatternLab\PatternData\Helpers\PatternCodeHelper; use \PatternLab\PatternData\Helpers\PatternStateHelper; +use \PatternLab\PatternData\Helpers\RawPatternHelper; use \PatternLab\Timer; class PatternData { @@ -153,6 +154,17 @@ public static function gather($options = array()) { $dataMergeExporter = new DataMergeExporter(); $dataMergeExporter->run(); + // dispatch that the raw pattern helper is about to start + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.rawPatternHelperStart",$event); + + // add the lineage info to PatternData::$store + $rawPatternHelper = new RawPatternHelper(); + $rawPatternHelper->run(); + + // dispatch that the raw pattern helper is ended + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.rawPatternHelperEnd",$event); // add the lineage info to PatternData::$store $lineageHelper = new LineageHelper(); $lineageHelper->run(); diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 81fa23e5..58048669 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -46,31 +46,6 @@ public function run() { $patternFoot = Template::getPatternFoot(); $stringLoader = Template::getStringLoader(); - // load the pattern data - $store = PatternData::get(); - - // iterate to get raw data loaded into the PatternData Store - foreach ($store as $patternStoreKey => $patternStoreData) { - - if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { - - // figure out the source path for the pattern to render - $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; - - // load the raw data so it can be modified/rendered - if (file_exists($patternSourceDir."/".$srcPath.".".$patternExtension)) { - PatternData::setPatternOption($patternStoreKey,"patternRaw",file_get_contents($patternSourceDir."/".$srcPath.".".$patternExtension)); - } else { - Console::writeWarning($patternStoreData["partial"]." wasn't found for loading. i have no idea why... "); - } - - } - - } - - // dispatch event - Dispatcher::getInstance()->dispatch("patternCodeHelper.rawPatternLoaded"); - // re-load the pattern data since we modified it $store = PatternData::get(); diff --git a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php new file mode 100644 index 00000000..55869f9f --- /dev/null +++ b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php @@ -0,0 +1,63 @@ + $patternStoreData) { + + if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { + + // figure out the source path for the pattern to render + $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; + + // load the raw data so it can be modified/rendered + $path = $patternSourceDir."/".$srcPath.".".$patternExtension; + if (file_exists($path)) { + PatternData::setPatternOption($patternStoreKey,"patternRaw",file_get_contents($path)); + } else { + Console::writeError($patternStoreData["partial"]." wasn't found for loading. the given path: ".$path); + } + + } + + } + + } + +} From f70bef1a0302e0ce85d1a07eff8e76dc1f6672e3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 20:16:18 -0500 Subject: [PATCH 190/436] adding support for extra events --- src/PatternLab/PatternData.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 0db200ef..43239f30 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -165,14 +165,31 @@ public static function gather($options = array()) { // dispatch that the raw pattern helper is ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.rawPatternHelperEnd",$event); + + // dispatch that the lineage helper is about to start + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.lineageHelperStart",$event); + // add the lineage info to PatternData::$store $lineageHelper = new LineageHelper(); $lineageHelper->run(); + // dispatch that the lineage helper is ended + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.lineageHelperEnd",$event); + + // dispatch that the pattern state helper is about to start + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.patternStateHelperStart",$event); + // using the lineage info update the pattern states on PatternData::$store $patternStateHelper = new PatternStateHelper(); $patternStateHelper->run(); + // dispatch that the pattern state helper is ended + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.patternStateHelperEnd",$event); + // set-up code pattern paths $ppdExporter = new PatternPathSrcExporter(); $patternPathSrc = $ppdExporter->run(); @@ -189,6 +206,10 @@ public static function gather($options = array()) { $patternCodeHelper = new PatternCodeHelper($options); $patternCodeHelper->run(); + // dispatch that the pattern code helper is ended + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.patternCodeHelperEnd",$event); + // dispatch that the gather has ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.gatherEnd",$event); From 6ea1016036ffa45db88f48fa2c686a77cb4938d6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 20:16:53 -0500 Subject: [PATCH 191/436] adding support for configuring lineage options in the config --- .../PatternData/Helpers/LineageHelper.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index e81fb736..419a9225 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -19,10 +19,16 @@ class LineageHelper extends \PatternLab\PatternData\Helper { + protected $lineageMatch; + protected $lineageMatchKey; + public function __construct($options = array()) { parent::__construct($options); + $this->lineageMatch = Config::getOption("lineageMatch"); + $this->lineageMatchKey = Config::getOption("lineageMatchKey"); + } public function run() { @@ -160,14 +166,13 @@ public function run() { /** * Get the lineage for a given pattern by parsing it and matching mustache partials - * @param {String} the filename for the pattern to be parsed + * @param {String} the data from the raw pattern * * @return {Array} a list of patterns */ - protected function findLineages($filename) { - $data = file_get_contents($filename); - if (preg_match_all('/{{>([ ]+)?([A-Za-z0-9-_]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ]+)?}}/',$data,$matches)) { - return array_unique($matches[2]); + protected function findLineages($data) { + if (preg_match_all("/".$this->lineageMatch."/",$data,$matches)) { + return array_unique($matches[$this->lineageMatchKey]); } return array(); } From 5baf3018ebbde80e6afc5215102b2ae4200ddb0d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 20:17:22 -0500 Subject: [PATCH 192/436] grabbing the raw pattern data from the pattern store data instead of going to disk --- src/PatternLab/PatternData/Helpers/LineageHelper.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 419a9225..430612f3 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -45,12 +45,8 @@ public function run() { if (($patternStoreData["category"] == "pattern") && (!isset($patternStoreData["pseudo"]))) { $patternLineages = array(); - $fileName = $patternStoreData["pathName"].".".$patternExtension; - $fileNameFull = $patternSourceDir."/".$fileName; - - if (file_exists($fileNameFull)) { - $foundLineages = $this->findLineages($fileNameFull); - } + $fileData = isset($patternStoreData["patternRaw"]) ? $patternStoreData["patternRaw"] : ""; + $foundLineages = $this->findLineages($fileData); if (!empty($foundLineages)) { From 82e55f96627f3c8bf44d9097f58e5f24e0e33461 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 Mar 2015 20:17:33 -0500 Subject: [PATCH 193/436] providing an updated error --- src/PatternLab/PatternData/Helpers/LineageHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 430612f3..bcaf37fb 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -60,6 +60,7 @@ public function run() { } else { if (strpos($lineage, '/') === false) { + $fileName = $patternStoreData["pathName"].".".$patternExtension; Console::writeWarning("you may have a typo in ".$fileName.". {{> ".$lineage." }} is not a valid pattern..."); } From a7b4b7d99f3df115d626f9e5748e1fbcb3225604 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 08:20:10 -0500 Subject: [PATCH 194/436] adding an html entity decode because json/yaml not liking the quotes --- src/PatternLab/PatternData/Helpers/LineageHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index bcaf37fb..9f9a5648 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -26,7 +26,7 @@ public function __construct($options = array()) { parent::__construct($options); - $this->lineageMatch = Config::getOption("lineageMatch"); + $this->lineageMatch = html_entity_decode(Config::getOption("lineageMatch"),ENT_QUOTES); $this->lineageMatchKey = Config::getOption("lineageMatchKey"); } From 99ccefa297551d7a699d9413220e2dd6fe23d666 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 11:08:04 -0500 Subject: [PATCH 195/436] making sure default assets aren't installed as a styleguidekit --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index f0a72bff..e1e9afc6 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -578,7 +578,7 @@ protected static function runTasks($event,$type) { self::scanForPatternEngineRule($pathBase); } else if ($type == "patternlab-starterkit") { Config::updateConfigOption("starterKit",$name); - } else if (($type == "patternlab-styleguidekit") && (strpos($type,"-assets-") === false)) { + } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { Config::updateConfigOption("styleguideKit",$name); } From cef7720b4b1603ca8fea7eb98fb027e625dd53c7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 11:20:58 -0500 Subject: [PATCH 196/436] need to test install of config options --- src/PatternLab/InstallerUtil.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index e1e9afc6..c258dcee 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -158,6 +158,8 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) // see if we need to modify the config if (isset($composerExtra["config"])) { + print_r($composerExtra["config"]); + foreach ($composerExtra["config"] as $optionInfo) { // get config info From 4ba749fe5526dbab3465e254d4ea5921270112be Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 11:33:24 -0500 Subject: [PATCH 197/436] simplifying the config path --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index ec97c79e..ed3b66b2 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -105,7 +105,7 @@ public static function init($baseDir = "", $verbose = true) { self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; - self::$plConfigPath = self::$options["baseDir"]."/vendor/pattern-lab/core/".self::$plConfigPath; + self::$plConfigPath = self::$options["baseDir"]."vendor/pattern-lab/core/".self::$plConfigPath; self::$dirAdded = true; // just in case the config directory doesn't exist at all From d4da7657514bfff223a7166599fb9e4c44ee17a0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 11:41:24 -0500 Subject: [PATCH 198/436] more debug --- src/PatternLab/InstallerUtil.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index c258dcee..8fb6d0ef 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -166,6 +166,8 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) $option = key($optionInfo); $value = $optionInfo[$option]; + Console::writeLine($option.": ".$value); + // update the config option Config::updateConfigOption($option,$value); From 6b9c468d97490abf39c02276df210aff6d81ad3c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 12:09:57 -0500 Subject: [PATCH 199/436] simplifying the config update --- src/PatternLab/InstallerUtil.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 8fb6d0ef..7e16d8fc 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -158,15 +158,7 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) // see if we need to modify the config if (isset($composerExtra["config"])) { - print_r($composerExtra["config"]); - - foreach ($composerExtra["config"] as $optionInfo) { - - // get config info - $option = key($optionInfo); - $value = $optionInfo[$option]; - - Console::writeLine($option.": ".$value); + foreach ($composerExtra["config"] as $option => $value) { // update the config option Config::updateConfigOption($option,$value); From bd2b334c43542641cfe745184316a3f6af2c7c30 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 17:25:10 -0500 Subject: [PATCH 200/436] updating deps --- composer.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index dbc2f835..118be183 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ "prefer-stable": true, "require": { "php": ">=5.3.6", - "michelf/php-markdown": "1.*", - "symfony/yaml": "2.*", - "seld/jsonlint": "1.*", - "symfony/event-dispatcher": "2.*", - "symfony/filesystem": "2.*", - "symfony/finder": "2.*", - "kevinlebrun/colors.php": "0.*", - "pattern-lab/unified-asset-installer": "0.*", - "alchemy/zippy": "0.*" + "michelf/php-markdown": "~1.5", + "symfony/yaml": "~2.6", + "seld/jsonlint": "~1.3", + "symfony/event-dispatcher": "~2.6", + "symfony/filesystem": "~2.6", + "symfony/finder": "~2.6", + "kevinlebrun/colors.php": "~0.4", + "pattern-lab/unified-asset-installer": "~0.5", + "alchemy/zippy": "0.2.1" } } From cf56658965402164408d8ee56781a01f273ff6ce Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 17:38:17 -0500 Subject: [PATCH 201/436] explicitly setting colors --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 118be183..87dfb251 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "symfony/event-dispatcher": "~2.6", "symfony/filesystem": "~2.6", "symfony/finder": "~2.6", - "kevinlebrun/colors.php": "~0.4", + "kevinlebrun/colors.php": "0.4.1", "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "0.2.1" } From 62d624fbe8332798442f1c3f4ae3c8d92e066e21 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 17:45:06 -0500 Subject: [PATCH 202/436] reordering --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 87dfb251..90591553 100644 --- a/composer.json +++ b/composer.json @@ -32,11 +32,11 @@ "require": { "php": ">=5.3.6", "michelf/php-markdown": "~1.5", - "symfony/yaml": "~2.6", "seld/jsonlint": "~1.3", "symfony/event-dispatcher": "~2.6", "symfony/filesystem": "~2.6", "symfony/finder": "~2.6", + "symfony/yaml": "~2.6", "kevinlebrun/colors.php": "0.4.1", "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "0.2.1" From 45e9b05eb69bf674c1a12707137af4392c6e4fb9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 17:50:42 -0500 Subject: [PATCH 203/436] updating dependencies --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 90591553..e1e30ed0 100644 --- a/composer.json +++ b/composer.json @@ -31,12 +31,12 @@ "prefer-stable": true, "require": { "php": ">=5.3.6", - "michelf/php-markdown": "~1.5", - "seld/jsonlint": "~1.3", - "symfony/event-dispatcher": "~2.6", - "symfony/filesystem": "~2.6", - "symfony/finder": "~2.6", - "symfony/yaml": "~2.6", + "michelf/php-markdown": "1.5.*", + "seld/jsonlint": "1.3.*", + "symfony/event-dispatcher": "2.6.*", + "symfony/filesystem": "2.6.*", + "symfony/finder": "2.6.*", + "symfony/yaml": "2.6.*", "kevinlebrun/colors.php": "0.4.1", "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "0.2.1" From 6bb7c7b393c8e65635ca1bea1cd309f302aed5d4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 17:56:58 -0500 Subject: [PATCH 204/436] explicit dependencies --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index e1e30ed0..20be5945 100644 --- a/composer.json +++ b/composer.json @@ -31,12 +31,12 @@ "prefer-stable": true, "require": { "php": ">=5.3.6", - "michelf/php-markdown": "1.5.*", - "seld/jsonlint": "1.3.*", - "symfony/event-dispatcher": "2.6.*", - "symfony/filesystem": "2.6.*", - "symfony/finder": "2.6.*", - "symfony/yaml": "2.6.*", + "michelf/php-markdown": "1.5.0", + "seld/jsonlint": "1.3.1", + "symfony/event-dispatcher": "2.6.4", + "symfony/filesystem": "2.6.4", + "symfony/finder": "2.6.4", + "symfony/yaml": "2.6.4", "kevinlebrun/colors.php": "0.4.1", "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "0.2.1" From 36f899d7f3b939653bb136892d68903a853b9f97 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 19:54:06 -0500 Subject: [PATCH 205/436] adding $fs call --- src/PatternLab/Fetch.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index bf698d24..6dc10a34 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -119,6 +119,7 @@ public function fetchStarterKit($starterkit = "") { // remove the temp files Console::writeInfo("cleaning up the temp files..."); + $fs = new Filesystem(); $fs->remove($tempFile); $fs->remove($tempDir); From 2cacebc9d5320e0334079a7ad900dd975b8a5296 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 20:09:10 -0500 Subject: [PATCH 206/436] adding dispatcher init --- src/PatternLab/InstallerUtil.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 7e16d8fc..b327fbd9 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -56,6 +56,8 @@ protected static function init() { $baseDir = __DIR__."/../../../../../"; Config::init($baseDir,false); + Dispatcher::init(); + } /** From 527734ed237ec512c9380450d61a0de3abe6c85d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 20:25:42 -0500 Subject: [PATCH 207/436] make the packages dir --- src/PatternLab/Dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Dispatcher.php b/src/PatternLab/Dispatcher.php index 10e1aff1..f6b1ee84 100644 --- a/src/PatternLab/Dispatcher.php +++ b/src/PatternLab/Dispatcher.php @@ -48,9 +48,9 @@ protected static function loadListeners() { // default var $packagesDir = Config::getOption("packagesDir"); - // see if the package dir exists. if it doesn't it means composer hasn't been run + // see if the package dir exists. if it doesn't make it if (!is_dir($packagesDir)) { - Console::writeError("you haven't fully set-up Pattern Lab yet. please add a pattern engine..."); + mkdir($packagesDir); } // make sure the listener data exists From 0ae3b00d7bcaa1b33ef3e01aab2936cbbf9825d7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 7 Mar 2015 20:31:17 -0500 Subject: [PATCH 208/436] starting the timer --- src/PatternLab/InstallerUtil.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index b327fbd9..0477c468 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -49,6 +49,9 @@ protected static function buildFileList($initialList) { */ protected static function init() { + // start the timer + Timer::start(); + // initialize the console to print out any issues Console::init(); From b06956873a81cf6921a3488e8892e1ee2dd0aa89 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 10 Mar 2015 14:28:08 -0400 Subject: [PATCH 209/436] adding support for customizing host and port --- src/PatternLab/Console/Commands/ServerCommand.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index 4582c5b5..f233890b 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -24,6 +24,8 @@ public function __construct() { $this->command = "server"; Console::setCommand($this->command,"Start the PHP-based server","The server command will start PHP's web server for you.","s"); + Console::setCommandOption($this->command,"host:","Provide a custom hostname. Default value is localhost.","To use a custom hostname:","",""); + Console::setCommandOption($this->command,"port:","Provide a custom port. Default value is 8080.","To use a custom port:","",""); } @@ -39,9 +41,15 @@ public function run() { $publicDir = Config::getOption("publicDir"); $coreDir = Config::getOption("coreDir"); + $host = Console::findCommandOptionValue("host"); + $host = $host ? $host : "localhost"; + + $port = Console::findCommandOptionValue("port"); + $host = $port ? $host.":".$port : $host.":8080"; + // start-up the server with the router - Console::writeInfo("server started on localhost:8080. use ctrl+c to exit..."); - passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S localhost:8080 ".$coreDir."/server/router.php"); + Console::writeInfo("server started on ".$host.". use ctrl+c to exit..."); + passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S ".$host." ".$coreDir."/server/router.php"); } From 7c381feb2a67efec92dfefa3f27748686d1ebfef Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 27 Mar 2015 10:52:47 -0400 Subject: [PATCH 210/436] adding host and port options to --server command --- src/PatternLab/Console/Commands/ServerCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index f233890b..ac3ef817 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -24,8 +24,9 @@ public function __construct() { $this->command = "server"; Console::setCommand($this->command,"Start the PHP-based server","The server command will start PHP's web server for you.","s"); - Console::setCommandOption($this->command,"host:","Provide a custom hostname. Default value is localhost.","To use a custom hostname:","",""); - Console::setCommandOption($this->command,"port:","Provide a custom port. Default value is 8080.","To use a custom port:","",""); + Console::setCommandOption($this->command,"host:","Provide a custom hostname. Default value is localhost.","To use a custom hostname and the default port:","",""); + Console::setCommandOption($this->command,"port:","Provide a custom port. Default value is 8080.","To use a custom port and the default hostname:","",""); + Console::setCommandSample($this->command,"To provide both a custom hostname and port:","--host --port "); } From 5bf17c198e3b75729c14f997cabf1a06690acfc3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 27 Mar 2015 10:54:48 -0400 Subject: [PATCH 211/436] watch for changes to the starterkit --- src/PatternLab/Console/Commands/WatchCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index fb322c14..fc85b81e 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -28,7 +28,7 @@ public function __construct() { Console::setCommand($this->command,"Watch for changes and regenerate","The watch command builds Pattern Lab, watches for changes in source/ and regenerates Pattern Lab when there are any.","w"); Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To turn off the cacheBuster:","n"); - Console::setCommandOption($this->command,"starterkit","Watch for changes to the StarterKit and copy to source/. The --starterkit flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:","s"); + Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to source/. The --starterkit flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:"); //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); } @@ -44,7 +44,7 @@ public function run() { // $options["autoReload"] = Console::findCommandOption("r|autoreload"); // see if the starterKit flag was passed so you know what dir to watch - if (Console::findCommandOption("s|starterkit")) { + if (Console::findCommandOption("sk")) { // load the starterkit watcher $w = new Watcher(); From b563a194e493d2fa9f9f9b1be85c5292bbb07098 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 27 Mar 2015 10:55:16 -0400 Subject: [PATCH 212/436] new sayings --- src/PatternLab/Generator.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index 72659213..5817d2eb 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -176,7 +176,7 @@ public function printSaying() { "namaste", "walk as if you are kissing the earth with your feet", "to be beautiful means to be yourself", - "i was thinking of the immortal words of socrates, who said \"...i drank what?\"", + "i was thinking of the immortal words of socrates, who said '...i drank what?'", "let me take this moment to compliment you on your fashion sense, particularly your slippers", "42", "he who controls the spice controls the universe", @@ -188,8 +188,26 @@ public function printSaying() { "mama always said life was like a box of chocolates. you never know what you're gonna get", "soylent green is people", "a little word of advice, my friend. sometimes you gotta let those hard-to-reach chips go", + "you don't understand! i coulda had class. i coulda been a contender. i could've been somebody, instead of a bum, which is what i am", "shop smart. shop s-mart", + "i see dead people", + "well, nobody's perfect", + "it's alive! it's alive!", + "you've got to ask yourself one question: 'do I feel lucky?' well, do ya, punk?", + "badges? we ain't got no badges! we don't need no badges! i don't have to show you any stinking badges!", + "the holy roman empire was neither holy nor roman. discuss.", + "well, here's another nice mess you've gotten me into!", + "here's johnny!", + "hello, gorgeous", + "nobody puts baby in a corner", + "life moves pretty fast. if you don't stop and look around once in a while, you could miss it", + "my precious", + "be yourself; everyone else is already taken", + "the ships hung in the sky in much the same way that bricks don't", "klaatu barada nikto", + "i am putting myself to the fullest possible use, which is all i think that any conscious entity can ever hope to do", + "just what do you think you're doing, dave?", + "do what i do. hold tight and pretend it's a plan!", "(╯°□°)╯︵ ┻━┻", "¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>", "@}~}~~~", From 567a9269388474218667601eb6b6756dd8ddbd97 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 27 Mar 2015 11:00:40 -0400 Subject: [PATCH 213/436] updating copy --- src/PatternLab/Console/Commands/WatchCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index fc85b81e..0d5eb192 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -27,8 +27,9 @@ public function __construct() { Console::setCommand($this->command,"Watch for changes and regenerate","The watch command builds Pattern Lab, watches for changes in source/ and regenerates Pattern Lab when there are any.","w"); Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); - Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To turn off the cacheBuster:","n"); - Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to source/. The --starterkit flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:"); + Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To watch and turn off the cache buster:","n"); + Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to source/. The --sk flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:"); + Console::setCommandSample($this->command,"To watch only patterns and turn off the cache buster:","--patternsonly --nocache"); //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); } From be1689d61e9f874217b739b9e71bd4426b7f2165 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 27 Mar 2015 11:01:58 -0400 Subject: [PATCH 214/436] supporting pattern extensions in the watcher --- src/PatternLab/Watcher.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 943d2120..a7b93e80 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -86,6 +86,7 @@ public function watch($options = array()) { $sourceDir = Config::getOption("sourceDir"); $ignoreExts = Config::getOption("ie"); $ignoreDirs = Config::getOption("id"); + $patternExt = Config::getOption("patternExtension"); // run forever while (true) { @@ -105,7 +106,7 @@ public function watch($options = array()) { $fileName = str_replace($sourceDir."/_patterns".DIRECTORY_SEPARATOR,"",$name); $fileNameClean = str_replace(DIRECTORY_SEPARATOR."_",DIRECTORY_SEPARATOR,$fileName); - if ($object->isFile() && (($object->getExtension() == "mustache") || ($object->getExtension() == "json") || ($object->getExtension() == "md"))) { + if ($object->isFile() && (($object->getExtension() == $patternExt) || ($object->getExtension() == "json") || ($object->getExtension() == "md"))) { // make sure this isn't a hidden pattern $patternParts = explode(DIRECTORY_SEPARATOR,$fileName); @@ -121,8 +122,8 @@ public function watch($options = array()) { } else if (!isset($o->patterns->$fileName) && $c) { $o->patterns->$fileName = $mt; $this->updateSite($fileName,"added"); - if ($object->getExtension() == "mustache") { - $patternSrcPath = str_replace(".mustache","",$fileName); + if ($object->getExtension() == $patternExt) { + $patternSrcPath = str_replace(".".$patternExt,"",$fileName); $patternDestPath = str_replace("/","-",$patternSrcPath); $render = ($pattern[0] != "_") ? true : false; $this->patternPaths[$patternParts[0]][$pattern] = array("patternSrcPath" => $patternSrcPath, "patternDestPath" => $patternDestPath, "render" => $render); From 00e4619c757b52367025e72494dd3d91d94c209d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 24 Apr 2015 14:38:04 -0400 Subject: [PATCH 215/436] removing the SK temp dir --- src/PatternLab/Fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 6dc10a34..9646f9bf 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -121,7 +121,7 @@ public function fetchStarterKit($starterkit = "") { Console::writeInfo("cleaning up the temp files..."); $fs = new Filesystem(); $fs->remove($tempFile); - $fs->remove($tempDir); + $fs->remove($tempDirSK); Console::writeInfo("the starterkit installation is complete..."); From 25b68e6dd2641f2babdba4c74a65a49245e4a571 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 24 Apr 2015 14:46:58 -0400 Subject: [PATCH 216/436] fixing spacing --- src/PatternLab/Fetch.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 9646f9bf..e21c3a05 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -34,13 +34,13 @@ public function fetchPackage($package = "") { if (empty($package)) { Console::writeError("please provide a path for the package before trying to fetch it..."); } - + // run composer $composerPath = Config::getOption("coreDir").DIRECTORY_SEPARATOR."bin/composer.phar"; passthru("php ".$composerPath." require ".$package); - - } + } + /** * Fetch a package from GitHub * @param {String} the command option to provide the rule for @@ -49,12 +49,12 @@ public function fetchPackage($package = "") { * @return {String} the modified file contents */ public function fetchStarterKit($starterkit = "") { - + // double-checks options was properly set if (empty($starterkit)) { Console::writeError("please provide a path for the starterkit before trying to fetch it..."); } - + // set default attributes $sourceDir = Config::getOption("sourceDir"); $tempDir = sys_get_temp_dir(); From 66f4712ce60aa6b4e38e3a495263f27135c6ccf5 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 24 Apr 2015 14:55:41 -0400 Subject: [PATCH 217/436] doing it as an array check instead --- src/PatternLab/Fetch.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index e21c3a05..092a81dc 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -165,13 +165,15 @@ protected function mirrorDist($sourceDir, $tempDirDist) { // set default vars $fsOptions = array(); $emptyDir = true; + $validFiles = array("README",".gitkeep",".DS_Store","styleguide"); // see if the source directory is empty if (is_dir($sourceDir)) { $objects = new \DirectoryIterator($sourceDir); foreach ($objects as $object) { - if (!$object->isDot() && ($object->getFilename() != "README") && ($object->getFilename() != ".DS_Store")) { + if (!$object->isDot() && !in_array($object->getFilename(),$validFiles)) { $emptyDir = false; + break; } } } From 83059029dcc99d0d170e6d105b8dd3e6ff5c810a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Apr 2015 15:16:45 -0400 Subject: [PATCH 218/436] exposing the patternExtension for use in other code --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index ed3b66b2..f5886246 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -207,6 +207,7 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("ishFontSize"); self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); + self::setExposedOption("patternExtension"); } From 6327a11e8fc5c4350f42185d75b1a1ef8e1319fc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Apr 2015 15:20:28 -0400 Subject: [PATCH 219/436] making sure listItems works --- src/PatternLab/Data.php | 8 ++++---- .../Rules/PatternInfoListItemsRule.php | 16 ++++++++-------- .../PatternData/Rules/PatternInfoRule.php | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 2097117f..48c1b1a4 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -23,7 +23,7 @@ class Data { protected static $store = array(); - protected static $reservedKeys = array("listItems","cacheBuster","link","patternSpecific","patternLabHead","patternLabFoot"); + protected static $reservedKeys = array("cacheBuster","link","patternSpecific","patternLabHead","patternLabFoot"); /** * Clear all of the data in the $store @@ -76,7 +76,7 @@ public static function gather($options = array()) { $data = array(); $fileName = $file->getFilename(); $hidden = ($fileName[0] == "_"); - $isListItems = strpos("listitems",$fileName); + $isListItems = strpos($fileName,"listitems"); $pathName = $file->getPathname(); $pathNameClean = str_replace($sourceDir."/","",$pathName); @@ -113,7 +113,7 @@ public static function gather($options = array()) { } else if ($isListItems !== false) { - $data = ($ext == "json") ? self::getListItems("data/listitems.json") : self::getListItems("data/listitems.yaml","yaml"); + $data = ($ext == "json") ? self::getListItems("_data/".$fileName) : self::getListItems("_data/".$fileName,"yaml"); if (!isset(self::$store["listItems"])) { self::$store["listItems"] = array(); @@ -159,7 +159,7 @@ public static function get() { * * @return {Array} the final set of list items */ - protected static function getListItems($filepath,$ext = "json") { + public static function getListItems($filepath,$ext = "json") { // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); diff --git a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php index 037bc5af..275f1178 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php @@ -51,18 +51,18 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternStoreData = array("category" => "pattern"); - $data = Data::getListItems($pathName,$ext); + $data = Data::getListItems("_patterns/".$pathName,$ext); $patternStoreData["listItems"] = $data; + // create a key for the data store + $patternStoreKey = $patternPartial; + + // if the pattern data store already exists make sure it is merged and overwrites this data + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + PatternData::setOption($patternStoreKey, $patternStoreData); + } - // create a key for the data store - $patternStoreKey = $patternPartial; - - // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; - PatternData::setOption($patternStoreKey, $patternStoreData); - } } diff --git a/src/PatternLab/PatternData/Rules/PatternInfoRule.php b/src/PatternLab/PatternData/Rules/PatternInfoRule.php index e02b6bad..d2509211 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoRule.php @@ -30,7 +30,7 @@ public function __construct($options) { $this->isDirProp = false; $this->isFileProp = true; $this->searchProp = ""; - $this->ignoreProp = "~"; + $this->ignoreProp = "~||listitems"; } From b3d7e0956eddf3ecb6f26628a2ce572094d47414 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 May 2015 15:07:47 -0400 Subject: [PATCH 220/436] dropping the > --- src/PatternLab/PatternData/Rules/PatternRule.php | 2 +- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index 3dfe8aed..bf2450a4 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -97,7 +97,7 @@ public function run($depth, $ext, $path, $pathName, $name) { if ($depth == 2) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; - $patternStoreData["breadcrumb"] = $patternTypeClean." > ".$patternSubtypeClean; + $patternStoreData["breadcrumb"] = $patternTypeClean." > ".$patternSubtypeClean; } // if the pattern data store already exists make sure it is merged and overwrites this data diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index adee85f9..0681106d 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -115,7 +115,7 @@ public function run($depth, $ext, $path, $pathName, $name) { if ($depth == 2) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; - $patternStoreData["breadcrumb"] = $patternType." > ".$patternSubtype; + $patternStoreData["breadcrumb"] = $patternType." > ".$patternSubtype; } $patternDataBase = array(); From 086e891e6dad23ce4acd603cb1b74775fbe87a83 Mon Sep 17 00:00:00 2001 From: Bryan Mills Date: Wed, 8 Jul 2015 15:38:44 -0400 Subject: [PATCH 221/436] Fix error on pattern path resolution in Windows caused by mixed directory separators. For a description of the problem: https://github.com/pattern-lab/edition-php-twig-standard/issues/6 --- src/PatternLab/PatternData.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 43239f30..23c62093 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -128,8 +128,8 @@ public static function gather($options = array()) { $isDir = $object->isDir(); $isFile = $object->isFile(); - $path = str_replace($patternSourceDir."/","",$object->getPath()); - $pathName = str_replace($patternSourceDir."/","",$object->getPathname()); + $path = str_replace($patternSourceDir.DIRECTORY_SEPARATOR,"",$object->getPath()); + $pathName = str_replace($patternSourceDir.DIRECTORY_SEPARATOR,"",$object->getPathname()); $name = $object->getFilename(); $depth = substr_count($pathName,DIRECTORY_SEPARATOR); From c32df6e54343f4612e5d966de6296c471251678d Mon Sep 17 00:00:00 2001 From: Ken Love Date: Tue, 11 Aug 2015 22:30:50 -0400 Subject: [PATCH 222/436] Create sub-directory for temp storage --- src/PatternLab/Fetch.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 6dc10a34..4bc6ceaf 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -57,7 +57,7 @@ public function fetchStarterKit($starterkit = "") { // set default attributes $sourceDir = Config::getOption("sourceDir"); - $tempDir = sys_get_temp_dir(); + $tempDir = sys_get_temp_dir().DIRECTORY_SEPARATOR."pl-sk"; $tempDirSK = $tempDir.DIRECTORY_SEPARATOR."pl-sk-archive"; $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist"; $tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR."composer.json"; @@ -75,6 +75,14 @@ public function fetchStarterKit($starterkit = "") { $error = error_get_last(); Console::writeError("the starterkit wasn't downloaded because:\n\n ".$error["message"]); } + + // Create temp directory if doesn't exist + $fs = new Filesystem(); + try { + $fs->mkdir($tempDir, 0775); + } catch (IOExceptionInterface $e) { + Console::writeError("Error creating temporary directory at " . $e->getPath()); + } // write the package to the temp directory $tempFile = tempnam($tempDir, "pl-sk-archive.tar.gz"); From 725e72b390a7877dcc95c39bd5bf5162bac40c1d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 1 Dec 2015 11:44:34 -0500 Subject: [PATCH 223/436] fixing a bug with using link. in the json files --- src/PatternLab/Data.php | 210 ++++++++++-------- .../Exporters/DataMergeExporter.php | 31 ++- src/PatternLab/Util.php | 30 +-- 3 files changed, 139 insertions(+), 132 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 48c1b1a4..ba44ddc5 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -21,17 +21,41 @@ use \Symfony\Component\Yaml\Yaml; class Data { - + protected static $store = array(); protected static $reservedKeys = array("cacheBuster","link","patternSpecific","patternLabHead","patternLabFoot"); - + /** * Clear all of the data in the $store */ public static function clear() { self::$store = array(); } - + + /** + * Go through data and replace any values that match items from the link.array + * @param {String} an entry from one of the list-based config entries + * + * @return {String} trimmed version of the given $v var + */ + public static function compareReplaceListVars(&$value) { + if (is_string($value)) { + $valueCheck = strtolower($value); + $valueThin = str_replace("link.","",$valueCheck); + $linkStore = self::getOption("link"); + if ((strpos($valueCheck, 'link.') !== false) && array_key_exists($valueThin,$linkStore)) { + $value = $linkStore[$valueThin]; + } + } + } + + /** + * Set-up the array_walk_recursive so that the data can be properly saved in scope + */ + public static function compareReplaceListVarsInit() { + array_walk_recursive(self::$store,'\PatternLab\Data::compareReplaceListVars'); + } + /** * Gather data from any JSON and YAML files in source/_data * @@ -44,13 +68,13 @@ public static function clear() { * @return {Array} populates Data::$store */ public static function gather($options = array()) { - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // dispatch that the data gather has started $dispatcherInstance->dispatch("data.gatherStart"); - + // default vars $found = false; $dataJSON = array(); @@ -58,20 +82,20 @@ public static function gather($options = array()) { $listItemsJSON = array(); $listItemsYAML = array(); $sourceDir = Config::getOption("sourceDir"); - + // iterate over all of the other files in the source directory if (!is_dir($sourceDir."/_data/")) { Console::writeWarning("_data/ doesn't exist so you won't have dynamic data..."); mkdir($sourceDir."/_data/"); } - + // find the markdown-based annotations $finder = new Finder(); $finder->files()->in($sourceDir."/_data/"); $finder->sortByName(); - + foreach ($finder as $name => $file) { - + $ext = $file->getExtension(); $data = array(); $fileName = $file->getFilename(); @@ -79,54 +103,56 @@ public static function gather($options = array()) { $isListItems = strpos($fileName,"listitems"); $pathName = $file->getPathname(); $pathNameClean = str_replace($sourceDir."/","",$pathName); - + if (!$hidden && (($ext == "json") || ($ext == "yaml"))) { - + if ($isListItems === false) { - + if ($ext == "json") { - + $file = file_get_contents($pathName); $data = json_decode($file,true); if ($jsonErrorMessage = JSON::hasError()) { JSON::lastErrorMsg($pathNameClean,$jsonErrorMessage,$data); } - + } else if ($ext == "yaml") { - + $file = file_get_contents($pathName); - + try { $data = YAML::parse($file); } catch (ParseException $e) { printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); } - + // single line of text won't throw a YAML error. returns as string if (gettype($data) == "string") { $data = array(); } - + } - - self::$store = array_replace_recursive(self::$store,$data); - + + if (is_array($data)) { + self::$store = array_replace_recursive(self::$store,$data); + } + } else if ($isListItems !== false) { - + $data = ($ext == "json") ? self::getListItems("_data/".$fileName) : self::getListItems("_data/".$fileName,"yaml"); - + if (!isset(self::$store["listItems"])) { self::$store["listItems"] = array(); } - + self::$store["listItems"] = array_replace_recursive(self::$store["listItems"],$data); - + } - + } - + } - + if (is_array(self::$store)) { foreach (self::$reservedKeys as $reservedKey) { if (array_key_exists($reservedKey,self::$store)) { @@ -134,15 +160,15 @@ public static function gather($options = array()) { } } } - + self::$store["cacheBuster"] = Config::getOption("cacheBuster"); self::$store["link"] = array(); self::$store["patternSpecific"] = array(); - + $dispatcherInstance->dispatch("data.gatherEnd"); - + } - + /** * Grab a copy of the $store * @@ -151,7 +177,7 @@ public static function gather($options = array()) { public static function get() { return self::$store; } - + /** * Generate the listItems array * @param {String} the filename for the pattern to be parsed @@ -160,90 +186,90 @@ public static function get() { * @return {Array} the final set of list items */ public static function getListItems($filepath,$ext = "json") { - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // dispatch that the data gather has started $dispatcherInstance->dispatch("data.getListItemsStart"); - + // default vars $sourceDir = Config::getOption("sourceDir"); $listItems = array(); $listItemsData = array(); - + // add list item data, makes 'listItems' a reserved word if (file_exists($sourceDir."/".$filepath)) { - + $file = file_get_contents($sourceDir."/".$filepath); - + if ($ext == "json") { $listItemsData = json_decode($file, true); if ($jsonErrorMessage = JSON::hasError()) { JSON::lastErrorMsg($filepath,$jsonErrorMessage,$listItems); } } else { - + try { $listItemsData = YAML::parse($file); } catch (ParseException $e) { printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); } - + // single line of text won't throw a YAML error. returns as string if (gettype($listItemsData) == "string") { $listItemsData = array(); } - + } - - + + $numbers = array("one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"); - + $i = 0; $k = 1; $c = count($listItemsData)+1; - + while ($k < $c) { - + shuffle($listItemsData); $itemsArray = array(); - + while ($i < $k) { $itemsArray[] = $listItemsData[$i]; $i++; } - + $listItems[$numbers[$k-1]] = $itemsArray; - + $i = 0; $k++; - + } - + } - + $dispatcherInstance->dispatch("data.getListItemsEnd"); - + return $listItems; - + } - + /** * Return the value for an option * * @return {String} the value of the option requested */ public static function getOption($optionName) { - + if (isset(self::$store[$optionName])) { return self::$store[$optionName]; } - + return false; - + } - + /** * Get the final data array specifically for a pattern * @param {String} the filename for the pattern to be parsed @@ -252,59 +278,59 @@ public static function getOption($optionName) { * @return {Array} the final set of list items */ public static function getPatternSpecificData($patternPartial,$extraData = array()) { - + // if there is pattern-specific data make sure to override the default in $this->d $d = self::get(); - + if (isset($d["patternSpecific"]) && array_key_exists($patternPartial,$d["patternSpecific"])) { - + if (!empty($d["patternSpecific"][$patternPartial]["data"])) { $d = array_replace_recursive($d, $d["patternSpecific"][$patternPartial]["data"]); } - + if (!empty($d["patternSpecific"][$patternPartial]["listItems"])) { - + $numbers = array("one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"); - + $k = 0; $c = count($d["patternSpecific"][$patternPartial]["listItems"]); - + while ($k < $c) { $section = $numbers[$k]; $d["listItems"][$section] = array_replace_recursive( $d["listItems"][$section], $d["patternSpecific"][$patternPartial]["listItems"][$section]); $k++; } - + } - + } - + if (!empty($extraData)) { $d = array_replace_recursive($d, $extraData); } - + unset($d["patternSpecific"]); - + return $d; - + } - + /** * Initialize a pattern specific data store under the patternSpecific option * @param {String} the pattern to create an array for */ public static function initPattern($optionName) { - + if (!isset(self::$store["patternSpecific"])) { self::$store["patternSpecific"] = array(); } - + if ((!isset(self::$store["patternSpecific"][$optionName])) || (!is_array(self::$store["patternSpecific"][$optionName]))) { self::$store["patternSpecific"][$optionName] = array(); } - + } - + /** * Print out the data var. For debugging purposes * @@ -313,52 +339,52 @@ public static function initPattern($optionName) { public static function printData() { print_r(self::$store); } - + /** * Set an option on a sub element of the data array * @param {String} name of the option * @param {String} value for the option */ public static function setOptionLink($optionName,$optionValue) { - + if (!isset(self::$store["link"])) { self::$store["link"] = array(); } - + self::$store["link"][$optionName] = $optionValue; - + } - + /** * Set the pattern data option * @param {String} name of the pattern * @param {String} value for the pattern's data attribute */ public static function setPatternData($optionName,$optionValue) { - + if (isset(self::$store["patternSpecific"][$optionName])) { self::$store["patternSpecific"][$optionName]["data"] = $optionValue; return true; } - + return false; - + } - + /** * Set the pattern listitems option * @param {String} name of the pattern * @param {String} value for the pattern's listItem attribute */ public static function setPatternListItems($optionName,$optionValue) { - + if (isset(self::$store["patternSpecific"][$optionName])) { self::$store["patternSpecific"][$optionName]["listItems"] = $optionValue; return true; } - + return false; - + } - + } diff --git a/src/PatternLab/PatternData/Exporters/DataMergeExporter.php b/src/PatternLab/PatternData/Exporters/DataMergeExporter.php index a074855c..39d683ed 100644 --- a/src/PatternLab/PatternData/Exporters/DataMergeExporter.php +++ b/src/PatternLab/PatternData/Exporters/DataMergeExporter.php @@ -18,40 +18,39 @@ use \PatternLab\Timer; class DataMergeExporter extends \PatternLab\PatternData\Exporter { - + public function __construct($options = array()) { - + parent::__construct($options); - + } - + public function run() { - + $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - + if ($patternStoreData["category"] == "pattern") { - + if (isset($patternStoreData["data"]) || isset($patternStoreData["listItems"])) { Data::initPattern($patternStoreKey); } - + if (isset($patternStoreData["data"])) { Data::setPatternData($patternStoreKey, $patternStoreData["data"]); } - + if (isset($patternStoreData["listItems"])) { Data::setPatternListItems($patternStoreKey, $patternStoreData["listItems"]); } - + } - + } - + // walk across the data and change link.pattern-partial to real source - $data = Data::get(); - array_walk_recursive($data,'\PatternLab\Util::compareReplace'); - + Data::compareReplaceListVarsInit(); + } - + } diff --git a/src/PatternLab/Util.php b/src/PatternLab/Util.php index 9efc488f..0589c41e 100644 --- a/src/PatternLab/Util.php +++ b/src/PatternLab/Util.php @@ -17,25 +17,7 @@ use \PatternLab\Timer; class Util { - - /** - * Go through data and replace any values that match items from the link.array - * @param {String} an entry from one of the list-based config entries - * - * @return {String} trimmed version of the given $v var - */ - public static function compareReplace(&$value) { - if (is_string($value)) { - $valueCheck = strtolower($value); - $valueThin = str_replace("link.","",$valueCheck); - $linkStore = Data::getOption("link"); - if ((strpos($valueCheck, 'link.') !== false) && array_key_exists($valueThin,$linkStore)) { - $value = $linkStore[$valueThin]; - } - } - - } - + /** * Lowercase the given string. Used in the array_walk() function in __construct as a sanity check * @param {String} an entry from one of the list-based config entries @@ -45,7 +27,7 @@ public static function compareReplace(&$value) { public static function strtolower(&$v) { $v = strtolower($v); } - + /** * Trim a given string. Used in the array_walk() function in __construct as a sanity check * @param {String} an entry from one of the list-based config entries @@ -55,19 +37,19 @@ public static function strtolower(&$v) { public static function trim(&$v) { $v = trim($v); } - + /** * Write out the time tracking file so the content sync service will work. A holdover * from how I put together the original AJAX polling set-up. */ public static function updateChangeTime() { - + if (is_dir(Config::getOption("publicDir"))) { file_put_contents(Config::getOption("publicDir")."/latest-change.txt",time()); } else { Console::writeError("the public directory for Pattern Lab doesn't exist..."); } - + } - + } From 20c7d508df22838a56b9565d99a9354b0c3b9970 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 1 Dec 2015 13:44:54 -0500 Subject: [PATCH 224/436] adding a better override method for pseudo-patterns --- src/PatternLab/PatternData.php | 286 +++++++++--------- .../PatternData/Rules/PseudoPatternRule.php | 58 ++-- 2 files changed, 172 insertions(+), 172 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 23c62093..3e18102a 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -27,7 +27,7 @@ use \PatternLab\Timer; class PatternData { - + protected static $store = array(); protected static $patternSubtype = ""; protected static $patternSubtypeClean = ""; @@ -39,39 +39,39 @@ class PatternData { protected static $rules = array(); protected static $dirSep = DIRECTORY_SEPARATOR; protected static $frontMeta = array("-","_"); - + /** * Return if a specific option is set * @param {String} the option to check */ public static function checkOption($optionName) { - + return isset(self::$store[$optionName]); - + } - + /** * Return if a specific option for a pattern is set * @param {String} the pattern to check * @param {String} the option to check */ public static function checkPatternOption($patternStoreKey,$optionName) { - + if (isset(self::$store[$patternStoreKey])) { return isset(self::$store[$patternStoreKey][$optionName]); } - + return false; - + } - + /** * Clear all of the data in the $store */ public static function clear() { self::$store = array(); } - + /** * Check to see if the given pattern type has a pattern subtype associated with it * @param {String} the name of the pattern @@ -86,173 +86,173 @@ public static function hasPatternSubtype($patternType) { } return false; } - + /** * Gather all of the information related to the patterns */ public static function gather($options = array()) { - + // set default vars $exportClean = (isset($options["exportClean"])) ? $options["exportClean"] : false; $exportFiles = (isset($options["exportClean"])) ? $options["exportFiles"] : false; $dispatcherInstance = Dispatcher::getInstance(); - + // cleaning the var for use below, i know this is stupid $options = array(); - + // dispatch that the data gather has started $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.gatherStart",$event); - + // load up the rules for parsing patterns and the directories self::loadRules($options); - + // dispatch that the rules are loaded $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.rulesLoaded",$event); - + // iterate over the patterns & related data and regenerate the entire site if they've changed // seems a little silly to use symfony finder here. not really giving me any power $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(Config::getOption("patternSourceDir")), \RecursiveIteratorIterator::SELF_FIRST); $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS); - + // sort the returned objects $patternObjects = iterator_to_array($patternObjects); ksort($patternObjects); - + $patternSourceDir = Config::getOption("patternSourceDir"); - + foreach ($patternObjects as $name => $object) { - + $ext = $object->getExtension(); $isDir = $object->isDir(); $isFile = $object->isFile(); - + $path = str_replace($patternSourceDir.DIRECTORY_SEPARATOR,"",$object->getPath()); $pathName = str_replace($patternSourceDir.DIRECTORY_SEPARATOR,"",$object->getPathname()); $name = $object->getFilename(); $depth = substr_count($pathName,DIRECTORY_SEPARATOR); - + // iterate over the rules and see if the current file matches one, if so run the rule foreach (self::$rules as $rule) { if ($rule->test($depth, $ext, $isDir, $isFile, $name)) { $rule->run($depth, $ext, $path, $pathName, $name); } } - + } - + // dispatch that the data is loaded $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.dataLoaded",$event); - + // make sure all of the appropriate pattern data is pumped into $this->d for rendering patterns $dataLinkExporter = new DataLinkExporter(); $dataLinkExporter->run(); - + // make sure all of the appropriate pattern data is pumped into $this->d for rendering patterns $dataMergeExporter = new DataMergeExporter(); $dataMergeExporter->run(); - + // dispatch that the raw pattern helper is about to start $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.rawPatternHelperStart",$event); - + // add the lineage info to PatternData::$store $rawPatternHelper = new RawPatternHelper(); $rawPatternHelper->run(); - + // dispatch that the raw pattern helper is ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.rawPatternHelperEnd",$event); - + // dispatch that the lineage helper is about to start $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.lineageHelperStart",$event); - + // add the lineage info to PatternData::$store $lineageHelper = new LineageHelper(); $lineageHelper->run(); - + // dispatch that the lineage helper is ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.lineageHelperEnd",$event); - + // dispatch that the pattern state helper is about to start $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.patternStateHelperStart",$event); - + // using the lineage info update the pattern states on PatternData::$store $patternStateHelper = new PatternStateHelper(); $patternStateHelper->run(); - + // dispatch that the pattern state helper is ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.patternStateHelperEnd",$event); - + // set-up code pattern paths $ppdExporter = new PatternPathSrcExporter(); $patternPathSrc = $ppdExporter->run(); $options = array(); $options["patternPaths"] = $patternPathSrc; - + // dispatch that the code helper is about to start $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.codeHelperStart",$event); - + // render out all of the patterns and store the generated info in PatternData::$store $options["exportFiles"] = $exportFiles; $options["exportClean"] = $exportClean; $patternCodeHelper = new PatternCodeHelper($options); $patternCodeHelper->run(); - + // dispatch that the pattern code helper is ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.patternCodeHelperEnd",$event); - + // dispatch that the gather has ended $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.gatherEnd",$event); - + } - + /** * Get the overall store of PatternData */ public static function get() { - + return self::$store; - + } - + /** * Get the directory separator */ public static function getDirSep() { return self::$dirSep; } - + /** * GEt the front meta bits (hidden and noviewall) */ public static function getFrontMeta() { return self::$frontMeta; } - + /** * Get a specific item from the store * @param {String} the option to check */ public static function getOption($optionName) { - + if (isset(self::$store[$optionName])) { return self::$store[$optionName]; } - + return false; - + } - + /** * Get a specific item from a pattern in the store data * @param {String} the name of the pattern @@ -261,129 +261,129 @@ public static function getOption($optionName) { * @return {String|Boolean} the value of false if it wasn't found */ public static function getPatternOption($patternStoreKey,$optionName) { - + if (isset(self::$store[$patternStoreKey][$optionName])) { return self::$store[$patternStoreKey][$optionName]; } - + return false; - + } - + /** * Get the pattern sub type */ public static function getPatternSubtype() { - + if (isset(self::$patternSubtype)) { return self::$patternSubtype; } - + return false; - + } - + /** * Get the pattern sub type clean */ public static function getPatternSubtypeClean() { - + if (isset(self::$patternSubtypeClean)) { return self::$patternSubtypeClean; } - + return false; - + } - + /** * Get the pattern sub type dash */ public static function getPatternSubtypeDash() { - + if (isset(self::$patternSubtypeDash)) { return self::$patternSubtypeDash; } - + return false; - + } - + /** * Get the pattern sub type set */ public static function getPatternSubtypeSet() { - + if (isset(self::$patternSubtypeSet)) { return self::$patternSubtypeSet; } - + return false; - + } - + /** * Get the pattern type */ public static function getPatternType() { - + if (isset(self::$patternType)) { return self::$patternType; } - + return false; - + } - + /** * Get the pattern type clean */ public static function getPatternTypeClean() { - + if (isset(self::$patternTypeClean)) { return self::$patternTypeClean; } - + return false; - + } - + /** * Get the pattern type dash */ public static function getPatternTypeDash() { - + if (isset(self::$patternTypeDash)) { return self::$patternTypeDash; } - + return false; - + } - + /** * Get a particular rule * @param {String} the name of the pattern */ public static function getRule($ruleName) { - + if (isset(self::$rules[$ruleName])) { return self::$rules[$ruleName]; } - + return false; - + } - + /** * Get all rules */ public static function getRules() { - + return self::$rules; - + } - + /** * Load all of the rules related to Pattern Data */ @@ -397,7 +397,7 @@ public static function loadRules($options) { } } } - + /** * Set an options value * @param {String} the name of the option to set @@ -406,16 +406,16 @@ public static function loadRules($options) { * @return {Boolean} if it was set or not */ public static function setOption($optionName,$optionValue) { - + if (isset(self::$store)) { self::$store[$optionName] = $optionValue; return true; } - + return false; - + } - + /** * Set a pattern option value * @param {String} the name of the pattern @@ -425,18 +425,18 @@ public static function setOption($optionName,$optionValue) { * @return {Boolean} if it was set or not */ public static function setPatternOption($patternStoreKey,$optionName,$optionValue) { - + if (isset(self::$store[$patternStoreKey])) { - + self::$store[$patternStoreKey][$optionName] = $optionValue; return true; - + } - + return false; - + } - + /** * Set a pattern option value for an option element that has an array * @param {String} the name of the pattern @@ -447,23 +447,23 @@ public static function setPatternOption($patternStoreKey,$optionName,$optionValu * @return {Boolean} if it was set or not */ public static function setPatternOptionArray($patternStoreKey,$optionName,$optionValue,$optionKey = "") { - + if (isset(self::$store[$patternStoreKey]) && isset(self::$store[$patternStoreKey][$optionName]) && is_array(self::$store[$patternStoreKey][$optionName])) { - + if (empty($optionKey)) { self::$store[$patternStoreKey][$optionName][] = $optionValue; } else { self::$store[$patternStoreKey][$optionName][$optionKey] = $optionValue; } - + return true; - + } - + return false; - + } - + /** * Set a pattern sub option value * @param {String} the name of the pattern @@ -475,99 +475,99 @@ public static function setPatternOptionArray($patternStoreKey,$optionName,$optio * @return {Boolean} if it was set or not */ public static function setPatternSubOption($patternStoreKey,$optionName,$patternSubStoreKey,$optionSubName,$optionSubValue) { - + if (isset(self::$store[$patternStoreKey]) && isset(self::$store[$patternStoreKey][$optionName]) && isset(self::$store[$patternStoreKey][$optionName][$patternSubStoreKey])) { - + self::$store[$patternStoreKey][$optionName][$patternLineageKey][$optionSubName] = $optionSubValue; return true; - + } - + return false; - + } - + /** * Set the pattern subtype * @param {String} the option value */ public static function setPatternSubtype($optionValue) { - + self::$patternSubtype = $optionValue; - + } - + /** * Set the pattern subtype clean * @param {String} the option value */ public static function setPatternSubtypeClean($optionValue) { - + self::$patternSubtypeClean = $optionValue; - + } - + /** * Set the pattern subtype dash * @param {String} the option value */ public static function setPatternSubtypeDash($optionValue) { - + self::$patternSubtypeDash = $optionValue; - + } - + /** * Set the pattern subtype set * @param {String} the option value */ public static function setPatternSubtypeSet($optionValue) { - + self::$patternSubtypeSet = $optionValue; - + } - + /** * Set the pattern type * @param {String} the option value */ public static function setPatternType($optionValue) { - + self::$patternType = $optionValue; - + } - + /** * Set the pattern type clean * @param {String} the option value */ public static function setPatternTypeClean($optionValue) { - + self::$patternTypeClean = $optionValue; - + } - + /** * Set the pattern type dash * @param {String} the option value */ public static function setPatternTypeDash($optionValue) { - + self::$patternTypeDash = $optionValue; - + } - + /** * Set a rule * @param {String} the name of the rule * @param {Object} the rule properties, guess this is a class too */ public static function setRule($ruleName, $rule) { - + self::$rules[$ruleName] = $rule; - + } - + /** * Update a property for a given rule * @param {String} the name of the rule to update @@ -578,14 +578,14 @@ public static function setRule($ruleName, $rule) { * @return {Boolean} whether the update was successful */ public function updateRuleProp($ruleName, $propName, $propValue, $action = "or") { - + if ($rule != self::getRule($ruleName)) { return false; } - + $rule->updateProp($propName, $propValue, $action); self::setRule($ruleName, $rule); - + } - + } diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 0681106d..242df147 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -20,22 +20,22 @@ use \Symfony\Component\Yaml\Yaml; class PseudoPatternRule extends \PatternLab\PatternData\Rule { - + public function __construct($options) { - + parent::__construct($options); - + $this->depthProp = 3; // 3 means that depth won't be checked $this->extProp = "json||yaml"; $this->isDirProp = false; $this->isFileProp = true; $this->searchProp = "~"; $this->ignoreProp = ""; - + } - + public function run($depth, $ext, $path, $pathName, $name) { - + // load default vars $patternSubtype = PatternData::getPatternSubtype(); $patternSubtypeDash = PatternData::getPatternSubtypeDash(); @@ -43,22 +43,22 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternTypeDash = PatternData::getPatternTypeDash(); $dirSep = PatternData::getDirSep(); $frontMeta = PatternData::getFrontMeta(); - + // should this pattern get rendered? $hidden = ($name[0] == "_"); $noviewall = ($name[0] == "-"); - + // set-up the names $patternFull = in_array($name[0],$frontMeta) ? substr($name,1) : $name; // 00-colors~foo.mustache $patternState = ""; - + // check for pattern state if (strpos($patternFull,"@") !== false) { $patternBits = explode("@",$patternFull,2); $patternState = str_replace(".".$ext,"",$patternBits[1]); $patternFull = preg_replace("/@(.*?)\./",".",$patternFull); } - + // finish setting up vars $patternBits = explode("~",$patternFull); $patternBase = $patternBits[0].".".Config::getOption("patternExtension"); // 00-homepage.mustache @@ -74,7 +74,7 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternPartial = $patternTypeDash."-".$patternDash; // pages-homepage-emergency $patternPath = str_replace(".".$ext,"",str_replace("~","-",$pathName)); // 00-atoms/01-global/00-colors $patternPathDash = str_replace($dirSep,"-",$patternPath); // 00-atoms-01-global-00-colors (file path) - + // check the original pattern path. if it doesn't exist make a guess $patternPathOrig = PatternData::getPatternOption($patternBaseOrig,"pathName"); // 04-pages/00-homepage $patternPathOrigDash = PatternData::getPatternOption($patternBaseOrig,"pathDash"); // 04-pages-00-homepage @@ -83,10 +83,10 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternPathOrig = $patternPathOrigBits[0]; // 04-pages/00-homepage $patternPathOrigDash = str_replace($dirSep,"-",$patternPathOrig); // 04-pages-00-homepage } - + // create a key for the data store $patternStoreKey = $patternPartial; - + // collect the data $patternStoreData = array("category" => "pattern", "name" => $pattern, @@ -110,14 +110,14 @@ public function run($depth, $ext, $path, $pathName, $name) { "original" => $patternBaseOrig, "pathOrig" => $patternPathOrig, "pathOrigDash" => $patternPathOrigDash); - + // add any subtype info if necessary if ($depth == 2) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; $patternStoreData["breadcrumb"] = $patternType." > ".$patternSubtype; } - + $patternDataBase = array(); if (file_exists(Config::getOption("patternSourceDir")."/".$path."/".$patternBaseData)) { $data = file_get_contents(Config::getOption("patternSourceDir")."/".$path."/".$patternBaseData); @@ -127,22 +127,22 @@ public function run($depth, $ext, $path, $pathName, $name) { JSON::lastErrorMsg($patternBaseJSON,$jsonErrorMessage,$data); } } else { - + try { $patternDataBase = YAML::parse($file); } catch (ParseException $e) { printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); } - + // single line of text won't throw a YAML error. returns as string if (gettype($patternDataBase) == "string") { $patternDataBase = array(); } - + } - + } - + // get the data for the pseudo-pattern $data = file_get_contents(Config::getOption("patternSourceDir")."/".$pathName); if ($ext == "json") { @@ -151,27 +151,27 @@ public function run($depth, $ext, $path, $pathName, $name) { JSON::lastErrorMsg($name,$jsonErrorMessage,$data); } } else { - + try { $patternData = YAML::parse($data); } catch (ParseException $e) { printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); } - + // single line of text won't throw a YAML error. returns as string if (gettype($patternData) == "string") { $patternData = array(); } - + } - + // make sure the pattern data is an array before merging the data - $patternStoreData["data"] = is_array($patternData) ? array_replace_recursive($patternDataBase, $patternData) : $patternDataBase; - + $patternStoreData["data"] = is_array($patternData) ? array_merge($patternDataBase, $patternData) : $patternDataBase; + // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_merge(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; PatternData::setOption($patternStoreKey, $patternStoreData); - + } - + } From 81a04e06c8a3d78c998e780fc8ceeda13d96fd9c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 1 Dec 2015 14:08:22 -0500 Subject: [PATCH 225/436] finally found the source of the bug --- src/PatternLab/Data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index ba44ddc5..006ef56f 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -285,7 +285,7 @@ public static function getPatternSpecificData($patternPartial,$extraData = array if (isset($d["patternSpecific"]) && array_key_exists($patternPartial,$d["patternSpecific"])) { if (!empty($d["patternSpecific"][$patternPartial]["data"])) { - $d = array_replace_recursive($d, $d["patternSpecific"][$patternPartial]["data"]); + $d = array_merge($d, $d["patternSpecific"][$patternPartial]["data"]); } if (!empty($d["patternSpecific"][$patternPartial]["listItems"])) { @@ -297,7 +297,7 @@ public static function getPatternSpecificData($patternPartial,$extraData = array while ($k < $c) { $section = $numbers[$k]; - $d["listItems"][$section] = array_replace_recursive( $d["listItems"][$section], $d["patternSpecific"][$patternPartial]["listItems"][$section]); + $d["listItems"][$section] = array_merge( $d["listItems"][$section], $d["patternSpecific"][$patternPartial]["listItems"][$section]); $k++; } From 221fe7a607ed29ac749fbf782e75c4f6839ea260 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 1 Dec 2015 15:24:20 -0500 Subject: [PATCH 226/436] adding '/patterns/' to the links --- .../Exporters/DataLinkExporter.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php index c345bde7..3d213b73 100644 --- a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php +++ b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php @@ -17,27 +17,27 @@ use \PatternLab\Timer; class DataLinkExporter extends \PatternLab\PatternData\Exporter { - + public function __construct($options = array()) { - + parent::__construct($options); - + } - + public function run() { - + $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - + if ($patternStoreData["category"] == "pattern") { - - $value = "../../".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; + + $value = "../../patterns/".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; Data::setOptionLink($patternStoreKey, $value); - + } - + } - + } - + } From 863750975792dfadbdd0a0bc0d15a223fbe8a77a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 3 Dec 2015 14:01:21 -0500 Subject: [PATCH 227/436] fixing a bug on windows when building the class path --- src/PatternLab/InstallerUtil.php | 342 +++++++++++++++---------------- 1 file changed, 171 insertions(+), 171 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 0477c468..059c1249 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -20,7 +20,7 @@ use \Symfony\Component\Finder\Finder; class InstallerUtil { - + /** * Move the component files from the package to their location in the patternlab-components dir * @param {String/Array} the items to create a fileList for @@ -28,9 +28,9 @@ class InstallerUtil { * @return {Array} list of files destination and source */ protected static function buildFileList($initialList) { - + $fileList = array(); - + // see if it's an array. loop over the multiple items if it is if (is_array($initialList)) { foreach ($initialList as $listItem) { @@ -39,30 +39,30 @@ protected static function buildFileList($initialList) { } else { $fileList[$listItem] = $listItem; } - + return $fileList; - + } - + /** * Common init sequence */ protected static function init() { - + // start the timer Timer::start(); - + // initialize the console to print out any issues Console::init(); - + // initialize the config for the pluginDir $baseDir = __DIR__."/../../../../../"; Config::init($baseDir,false); - + Dispatcher::init(); - + } - + /** * Parse the component types to figure out what needs to be moved and added to the component JSON files * @param {String} file path to move @@ -73,83 +73,83 @@ protected static function init() { * @param {Array} the list of files to be moved */ protected static function moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase) { - + $fs = new Filesystem(); - + // make sure the destination base exists if (!is_dir($destinationBase)) { $fs->mkdir($destinationBase); } - + // clean any * or / on the end of $destination $destination = (($destination != "*") && ($destination[strlen($destination)-1] == "*")) ? substr($destination,0,-1) : $destination; $destination = ($destination[strlen($destination)-1] == "/") ? substr($destination,0,-1) : $destination; - + // decide how to move the files. the rules: // src ~ dest -> action // * ~ * -> mirror all in {srcroot}/ to {destroot}/ // * ~ path/* -> mirror all in {srcroot}/ to {destroot}/path/ // foo/* ~ path/* -> mirror all in {srcroot}/foo/ to {destroot}/path/ // foo/s.html ~ path/k.html -> mirror {srcroot}/foo/s.html to {destroot}/path/k.html - + if (($source == "*") && ($destination == "*")) { - $result = self::pathExists($packageName, $destinationBase."/"); + $result = self::pathExists($packageName, $destinationBase.DIRECTORY_SEPARATOR); $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); - $fs->mirror($sourceBase, $destinationBase."/", null, $options); + $fs->mirror($sourceBase, $destinationBase.DIRECTORY_SEPARATOR, null, $options); } else if ($source == "*") { - $result = self::pathExists($packageName, $destinationBase."/".$destination); + $result = self::pathExists($packageName, $destinationBase.DIRECTORY_SEPARATOR.$destination); $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); - $fs->mirror($sourceBase, $destinationBase."/".$destination, null, $options); + $fs->mirror($sourceBase, $destinationBase.DIRECTORY_SEPARATOR.$destination, null, $options); } else if ($source[strlen($source)-1] == "*") { $source = rtrim($source,"/*"); - $result = self::pathExists($packageName, $destinationBase."/".$destination); + $result = self::pathExists($packageName, $destinationBase.DIRECTORY_SEPARATOR.$destination); $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); - $fs->mirror($sourceBase.$source, $destinationBase."/".$destination, null, $options); + $fs->mirror($sourceBase.$source, $destinationBase.DIRECTORY_SEPARATOR.$destination, null, $options); } else { - $pathInfo = explode("/",$destination); + $pathInfo = explode(DIRECTORY_SEPARATOR,$destination); $file = array_pop($pathInfo); - $destinationDir = implode("/",$pathInfo); - if (!$fs->exists($destinationBase."/".$destinationDir)) { - $fs->mkdir($destinationBase."/".$destinationDir); + $destinationDir = implode(DIRECTORY_SEPARATOR,$pathInfo); + if (!$fs->exists($destinationBase.DIRECTORY_SEPARATOR.$destinationDir)) { + $fs->mkdir($destinationBase.DIRECTORY_SEPARATOR.$destinationDir); } - $result = self::pathExists($packageName, $destinationBase."/".$destination); + $result = self::pathExists($packageName, $destinationBase.DIRECTORY_SEPARATOR.$destination); $override = ($result) ? true : false; - $fs->copy($sourceBase.$source, $destinationBase."/".$destination, $override); + $fs->copy($sourceBase.$source, $destinationBase.DIRECTORY_SEPARATOR.$destination, $override); } - + } - + /** * Parse the extra section from composer.json * @param {Object} the JSON for the composer extra section */ public static function parseComposerExtraList($composerExtra, $name, $pathDist) { - + // move assets to the base directory if (isset($composerExtra["dist"]["baseDir"])) { self::parseFileList($name,$pathDist,Config::getOption("baseDir"),$composerExtra["dist"]["baseDir"]); } - + // move assets to the public directory if (isset($composerExtra["dist"]["publicDir"])) { self::parseFileList($name,$pathDist,Config::getOption("publicDir"),$composerExtra["dist"]["publicDir"]); } - + // move assets to the source directory if (isset($composerExtra["dist"]["sourceDir"])) { self::parseFileList($name,$pathDist,Config::getOption("sourceDir"),$composerExtra["dist"]["sourceDir"]); } - + // move assets to the scripts directory if (isset($composerExtra["dist"]["scriptsDir"])) { self::parseFileList($name,$pathDist,Config::getOption("scriptsDir"),$composerExtra["dist"]["scriptsDir"]); } - + // move assets to the data directory if (isset($composerExtra["dist"]["dataDir"])) { self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$composerExtra["dist"]["dataDir"]); } - + // move assets to the components directory if (isset($composerExtra["dist"]["componentDir"])) { $templateExtension = isset($composerExtra["templateExtension"]) ? $composerExtra["templateExtension"] : "mustache"; @@ -159,21 +159,21 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) self::parseComponentList($name,$pathDist,$componentDir."/".$name,$composerExtra["dist"]["componentDir"],$templateExtension,$onready,$callback); self::parseFileList($name,$pathDist,$componentDir."/".$name,$composerExtra["dist"]["componentDir"]); } - + // see if we need to modify the config if (isset($composerExtra["config"])) { - + foreach ($composerExtra["config"] as $option => $value) { - + // update the config option Config::updateConfigOption($option,$value); - + } - + } - + } - + /** * Parse the component types to figure out what needs to be added to the component JSON files * @param {String} the name of the package @@ -185,9 +185,9 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) * @param {String} the javascript to run as a callback */ protected static function parseComponentList($packageName,$sourceBase,$destinationBase,$componentFileList,$templateExtension,$onready,$callback) { - + /* - iterate over a source or source dirs and copy files into the componentdir. + iterate over a source or source dirs and copy files into the componentdir. use file extensions to add them to the appropriate type arrays below. so... "patternlab": { "dist": { @@ -200,40 +200,40 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati "templateExtension": "" } } - + */ - + // decide how to type list files. the rules: // src ~ dest -> action // * ~ * -> iterate over all files in {srcroot}/ and create a type listing // foo/* ~ path/* -> iterate over all files in {srcroot}/foo/ and create a type listing // foo/s.html ~ path/k.html -> create a type listing for {srcroot}/foo/s.html - + // set-up component types store $componentTypes = array("stylesheets" => array(), "javascripts" => array(), "templates" => array()); - + // iterate over the file list foreach ($componentFileList as $componentItem) { - + // retrieve the source & destination $source = self::removeDots(key($componentItem)); $destination = self::removeDots($componentItem[$source]); - + if (($source == "*") || ($source[strlen($source)-1] == "*")) { - + // build the source & destination $source = (strlen($source) > 2) ? rtrim($source,"/*") : ""; $destination = (strlen($destination) > 2) ? rtrim($destination,"/*") : ""; - + // get files $finder = new Finder(); $finder->files()->in($sourceBase.$source); - + // iterate over the returned objects foreach ($finder as $file) { - + $ext = $file->getExtension(); - + if ($ext == "css") { $componentTypes["stylesheets"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); } else if ($ext == "js") { @@ -241,17 +241,17 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati } else if ($ext == $templateExtension) { $componentTypes["templates"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); } - + } - + } else { - + $bits = explode(".",$source); - + if (count($bits) > 0) { - + $ext = $bits[count($bits)-1]; - + if ($ext == "css") { $componentTypes["stylesheets"][] = $destination; } else if ($ext == "js") { @@ -259,13 +259,13 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati } else if ($ext == $templateExtension) { $componentTypes["templates"][] = $destination; } - + } - + } - + } - + /* FOR USE AS A PACKAGE TO BE LOADED LATER { @@ -289,21 +289,21 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati $packageInfo["onready"] = $onready; $packageInfo["callback"] = $callback; $packageInfoPath = Config::getOption("componentDir")."/packages/".str_replace("/","-",$packageName).".json"; - + // double-check the dirs are created if (!is_dir(Config::getOption("componentDir"))) { mkdir(Config::getOption("componentDir")); } - + if (!is_dir(Config::getOption("componentDir")."/packages/")) { mkdir(Config::getOption("componentDir")."/packages/"); } - + // write out the package info file_put_contents($packageInfoPath,json_encode($packageInfo)); - + } - + /** * Move the files from the package to their location in the public dir or source dir * @param {String} the name of the package @@ -312,20 +312,20 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati * @param {Array} the list of files to be moved */ protected static function parseFileList($packageName,$sourceBase,$destinationBase,$fileList) { - + foreach ($fileList as $fileItem) { - + // retrieve the source & destination $source = self::removeDots(key($fileItem)); $destination = self::removeDots($fileItem[$source]); - + // depending on the source handle things differently. mirror if it ends in /* self::moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase); - + } - + } - + /** * Check to see if the path already exists. If it does prompt the user to double-check it should be overwritten * @param {String} the package name @@ -334,20 +334,20 @@ protected static function parseFileList($packageName,$sourceBase,$destinationBas * @return {Boolean} if the path exists and should be overwritten */ protected static function pathExists($packageName,$path) { - + $fs = new Filesystem; - + if ($fs->exists($path)) { - + // set-up a human readable prompt $humanReadablePath = str_replace(Config::getOption("baseDir"), "./", $path); - + // set if the prompt should fire $prompt = true; - + // are we checking a directory? if (is_dir($path)) { - + // see if the directory is essentially empty $files = scandir($path); foreach ($files as $key => $file) { @@ -357,20 +357,20 @@ protected static function pathExists($packageName,$path) { unset($files[$key]); } } - + if (empty($files)) { $prompt = false; } - + } - + if ($prompt) { - + // prompt for input using the supplied query $prompt = "the path ".$humanReadablePath." already exists. merge or replace with the contents of ".$packageName." package?"; $options = "M/r"; $input = Console::promptInput($prompt,$options); - + if ($input == "m") { Console::writeTag("ok","contents of ".$humanReadablePath." have been merged with the package's content...", false, true); return false; @@ -378,160 +378,160 @@ protected static function pathExists($packageName,$path) { Console::writeWarning("contents of ".$humanReadablePath." have been replaced by the package's content...", false, true); return true; } - + } - + return false; - + } - + return false; - + } - + /** * Run the PL tasks when a package is installed * @param {Object} a script event object from composer */ public static function postPackageInstall($event) { - + // run the console and config inits self::init(); - + // run the tasks based on what's in the extra dir self::runTasks($event,"install"); - + } - + /** * Run the PL tasks when a package is updated * @param {Object} a script event object from composer */ public static function postPackageUpdate($event) { - + // run the console and config inits self::init(); - + self::runTasks($event,"update"); - + } - + /** * Ask questions after the create package is done * @param {Object} a script event object from composer */ public static function postCreateProjectCmd($event) { - + // see if there is an extra component $extra = $event->getComposer()->getPackage()->getExtra(); - + if (isset($extra["patternlab"])) { - + self::init(); Console::writeLine(""); - + // see if we have any starterkits to suggest if (isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) { - + $suggestions = $extra["patternlab"]["starterKitSuggestions"]; - + // suggest starterkits Console::writeInfo("suggested starterkits that work with this edition:", false, true); foreach ($suggestions as $i => $suggestion) { - + // write each suggestion $num = $i + 1; Console::writeLine($num.": ".$suggestion, true); - + } - + // prompt for input on the suggestions Console::writeLine(""); $prompt = "choose an option or hit return to skip:"; $options = "(ex. 1)"; $input = Console::promptInput($prompt,$options); $result = (int)$input - 1; - + if (isset($suggestions[$result])) { - + Console::writeLine(""); $f = new Fetch(); $result = $f->fetchStarterKit($suggestions[$result]); - + if ($result) { - + Console::writeLine(""); $g = new Generator(); $g->generate(array("foo" => "bar")); - + Console::writeLine(""); Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); - + } - + } else { - + Console::writeWarning("you will need to install a StarterKit before using Pattern Lab..."); - + } - + } - + } - + } - + /** * Make sure certain things are set-up before running the installation of a package * @param {Object} a script event object from composer */ public static function preInstallCmd($event) { - + // run the console and config inits self::init(); - + // default vars $sourceDir = Config::getOption("sourceDir"); $packagesDir = Config::getOption("packagesDir"); - + // check directories if (!is_dir($sourceDir)) { mkdir($sourceDir); } - + if (!is_dir($packagesDir)) { mkdir($packagesDir); } - + } - + /** * Make sure pattern engines and listeners are removed on uninstall * @param {Object} a script event object from composer */ public static function prePackageUninstallCmd($event) { - + // run the console and config inits self::init(); - + // get package info $package = $event->getOperation()->getPackage(); $type = $package->getType(); $name = $package->getName(); $pathBase = Config::getOption("packagesDir")."/".$name; - + // see if the package has a listener and remove it self::scanForListener($pathBase,true); - + // see if the package is a pattern engine and remove the rule if ($type == "patternlab-patternengine") { self::scanForPatternEngineRule($pathBase,true); } - + // go over .json in patternlab-components/, remove references to packagename - + } - + /** * Remove dots from the path to make sure there is no file system traversal when looking for or writing files * @param {String} the path to check and remove dots @@ -547,14 +547,14 @@ protected static function removeDots($path) { } return implode("/", $parts); } - + /** * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file * @param {Object} a script event object from composer * @param {String} the type of event starting the runTasks command */ protected static function runTasks($event,$type) { - + // get package info $package = ($type == "install") ? $event->getOperation()->getPackage() : $event->getOperation()->getTargetPackage(); $extra = $package->getExtra(); @@ -562,18 +562,18 @@ protected static function runTasks($event,$type) { $name = $package->getName(); $pathBase = Config::getOption("packagesDir")."/".$name; $pathDist = $pathBase."/dist/"; - + // make sure we're only evaluating pattern lab packages if (strpos($type,"patternlab-") !== false) { - + // make sure that it has the name-spaced section of data to be parsed. if it exists parse it if (isset($extra["patternlab"])) { self::parseComposerExtraList($extra["patternlab"], $name, $pathDist); } - + // see if the package has a listener self::scanForListener($pathBase); - + // address other specific needs based on type if ($type == "patternlab-patternengine") { self::scanForPatternEngineRule($pathBase); @@ -582,39 +582,39 @@ protected static function runTasks($event,$type) { } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { Config::updateConfigOption("styleguideKit",$name); } - + } - + } - + /** * Scan the package for a listener * @param {String} the path for the package */ protected static function scanForListener($pathPackage,$remove = false) { - + // get listener list path $pathList = Config::getOption("packagesDir")."/listeners.json"; - + // make sure listeners.json exists. if not create it if (!file_exists($pathList)) { file_put_contents($pathList, "{ \"listeners\": [ ] }"); } - + // load listener list $listenerList = json_decode(file_get_contents($pathList),true); - + // set-up a finder to find the listener $finder = new Finder(); $finder->files()->name('PatternLabListener.php')->in($pathPackage); - + // iterate over the returned objects foreach ($finder as $file) { - + // create the name - $dirs = explode("/",$file->getPath()); + $dirs = explode(DIRECTORY_SEPARATOR,$file->getPath()); $listenerName = "\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); - + // check to see what we should do with the listener info if (!$remove && !in_array($listenerName,$listenerList["listeners"])) { $listenerList["listeners"][] = $listenerName; @@ -622,42 +622,42 @@ protected static function scanForListener($pathPackage,$remove = false) { $key = array_search($listenerName, $listenerList["listeners"]); unset($listenerList["listeners"][$key]); } - + // write out the listener list file_put_contents($pathList,json_encode($listenerList)); - + } - + } - + /** * Scan the package for a pattern engine rule * @param {String} the path for the package */ protected static function scanForPatternEngineRule($pathPackage,$remove = false) { - + // get listener list path $pathList = Config::getOption("packagesDir")."/patternengines.json"; - + // make sure patternengines.json exists. if not create it if (!file_exists($pathList)) { file_put_contents($pathList, "{ \"patternengines\": [ ] }"); } - + // load pattern engine list $patternEngineList = json_decode(file_get_contents($pathList),true); - + // set-up a finder to find the pattern engine $finder = new Finder(); $finder->files()->name("PatternEngineRule.php")->in($pathPackage); - + // iterate over the returned objects foreach ($finder as $file) { - + /// create the name - $dirs = explode("/",$file->getPath()); + $dirs = explode(DIRECTORY_SEPARATOR,$file->getPath()); $patternEngineName = "\\".$dirs[count($dirs)-3]."\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); - + // check what we should do with the pattern engine info if (!$remove && !in_array($patternEngineName, $patternEngineList["patternengines"])) { $patternEngineList["patternengines"][] = $patternEngineName; @@ -665,12 +665,12 @@ protected static function scanForPatternEngineRule($pathPackage,$remove = false) $key = array_search($patternEngineName, $patternEngineList["patternengines"]); unset($patternEngineList["patternengines"][$key]); } - + // write out the pattern engine list file_put_contents($pathList,json_encode($patternEngineList)); - + } - + } - + } From 58fb7954bb8449d7d459213817e13e65217fb359 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 7 Dec 2015 15:29:57 -0500 Subject: [PATCH 228/436] making sure list.* will be replaced at any depth --- src/PatternLab/Data.php | 32 +++++++++-- src/PatternLab/PatternEngine/Util.php | 80 +++++++++++++-------------- 2 files changed, 66 insertions(+), 46 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 006ef56f..d0b69956 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -34,12 +34,12 @@ public static function clear() { /** * Go through data and replace any values that match items from the link.array - * @param {String} an entry from one of the list-based config entries + * @param {String} a string entry from the data to check for link.pattern * - * @return {String} trimmed version of the given $v var + * @return {String} replaced version of link.pattern */ - public static function compareReplaceListVars(&$value) { - if (is_string($value)) { + private static function compareReplaceListVars($value) { + if (is_string($value) && preg_match("/^link\.([\S]+)$/",$value)) { $valueCheck = strtolower($value); $valueThin = str_replace("link.","",$valueCheck); $linkStore = self::getOption("link"); @@ -47,13 +47,33 @@ public static function compareReplaceListVars(&$value) { $value = $linkStore[$valueThin]; } } + return $value; } /** - * Set-up the array_walk_recursive so that the data can be properly saved in scope + * Work through a given array and decide if the walk should continue or if we should replace the var + * @param {Array} the array to be checked + * + * @return {Array} the "fixed" array + */ + private static function recursiveWalk($array) { + foreach ($array as $k => $v) { + if (is_array($v)) { + $array[$k] = self::recursiveWalk($v); + } else { + $array[$k] = self::compareReplaceListVars($v); + } + } + return $array; + } + + /** + * Set-up the recursive walk so that the data can be properly saved */ public static function compareReplaceListVarsInit() { - array_walk_recursive(self::$store,'\PatternLab\Data::compareReplaceListVars'); + + self::$store = self::recursiveWalk(self::$store); + } /** diff --git a/src/PatternLab/PatternEngine/Util.php b/src/PatternLab/PatternEngine/Util.php index 64a8e774..bf09028b 100644 --- a/src/PatternLab/PatternEngine/Util.php +++ b/src/PatternLab/PatternEngine/Util.php @@ -15,18 +15,18 @@ use \PatternLab\Timer; class Util { - + protected $patternPaths = array(); - + /** * Set-up the pattern paths var */ public function __construct($options) { - + $this->patternPaths = $options["patternPaths"]; - + } - + /** * Helper function to find and replace the given parameters in a particular partial before handing it back to Mustache * @param {String} the file contents @@ -66,7 +66,7 @@ public function findReplaceParameters($fileData, $parameters) { } return $fileData; } - + /** * Helper function for getting a Mustache template file name. * @param {String} the pattern type for the pattern @@ -75,28 +75,28 @@ public function findReplaceParameters($fileData, $parameters) { * @return {Array} an array of rendered partials that match the given path */ public function getFileName($name,$ext) { - + $fileName = ""; $dirSep = DIRECTORY_SEPARATOR; - + // test to see what kind of path was supplied $posDash = strpos($name,"-"); $posSlash = strpos($name,$dirSep); - + if (($posSlash === false) && ($posDash !== false)) { $fileName = $this->getPatternFileName($name); } else { $fileName = $name; } - + if (substr($fileName, 0 - strlen($ext)) !== $ext) { $fileName .= $ext; } - + return $fileName; - + } - + /** * Helper function to return the pattern file name * @param {String} the name of the pattern @@ -104,11 +104,11 @@ public function getFileName($name,$ext) { * @return {String} the file path to the pattern */ public function getPatternFileName($name) { - + $patternFileName = ""; - + list($patternType,$pattern) = $this->getPatternInfo($name); - + // see if the pattern is an exact match for patternPaths. if not iterate over patternPaths to find a likely match if (isset($this->patternPaths[$patternType][$pattern])) { $patternFileName = $this->patternPaths[$patternType][$pattern]; @@ -121,11 +121,11 @@ public function getPatternFileName($name) { } } } - + return $patternFileName; - + } - + /** * Helper function to return the parts of a partial name * @param {String} the name of the partial @@ -133,9 +133,9 @@ public function getPatternFileName($name) { * @return {Array} the pattern type and the name of the pattern */ public function getPatternInfo($name) { - + $patternBits = explode("-",$name); - + $i = 1; $k = 2; $c = count($patternBits); @@ -145,14 +145,14 @@ public function getPatternInfo($name) { $i++; $k++; } - + $patternBits = explode("-",$name,$k); $pattern = $patternBits[count($patternBits)-1]; - + return array($patternType, $pattern); - + } - + /** * Helper function for finding if a partial name has style modifier or parameters * @param {String} the pattern name @@ -160,17 +160,17 @@ public function getPatternInfo($name) { * @return {Array} an array containing just the partial name, a style modifier, and any parameters */ public function getPartialInfo($partial) { - + $styleModifier = array(); $parameters = array(); - + if (strpos($partial, "(") !== false) { $partialBits = explode("(",$partial,2); $partial = trim($partialBits[0]); $parametersString = substr($partialBits[1],0,(strlen($partialBits[1]) - strlen(strrchr($partialBits[1],")")))); $parameters = $this->parseParameters($parametersString); } - + if (strpos($partial, ":") !== false) { $partialBits = explode(":",$partial,2); $partial = $partialBits[0]; @@ -181,11 +181,11 @@ public function getPartialInfo($partial) { } $styleModifier = array("styleModifier" => $styleModifier); } - + return array($partial,$styleModifier,$parameters); - + } - + /** * Helper function to parse the parameters and return them as an array * @param {String} the parameter string @@ -193,7 +193,7 @@ public function getPartialInfo($partial) { * @return {Array} the keys and values for the parameters */ private function parseParameters($string) { - + $parameters = array(); $arrayParameters = array(); $arrayOptions = array(); @@ -208,12 +208,12 @@ private function parseParameters($string) { $keyBuffer = ""; $arrayKeyBuffer = ""; $strLength = strlen($string); - + for ($i = 0; $i < $strLength; $i++) { - + $previousChar = $char; $char = $string[$i]; - + if ($inKey && !$betweenDQuotes && !$betweenSQuotes && (($char == "\"") || ($char == "'"))) { // if inKey, a quote, and betweenQuotes is false ignore quote, set betweenQuotes to true and empty buffer to kill spaces ($char == "\"") ? ($betweenDQuotes = true) : ($betweenSQuotes = true); @@ -300,18 +300,18 @@ private function parseParameters($string) { $buffer .= $char; } else if (!$inValue && !$inKey && ($char == ",")) { // if inValue is false, inKey false, and a comma set inKey true - if ($inArray && !$inOption) { + if ($inArray && !$inOption) { // don't do anything } else { $inKey = true; } - + } } - + return $parameters; - + } - + } From a57d3a3d378094977b8c3a01dc6329ce06a80a7b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 17 Dec 2015 14:48:09 -0500 Subject: [PATCH 229/436] just making sure we're close to being on the same page handling whitespace --- .editorconfig | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8dea9c9a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +indent_style = tab +trim_trailing_whitespace = false +end_of_line = lf +insert_final_newline = true From 3672d9e30787287f531f1319374d996575d2cc9f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 17 Dec 2015 14:59:18 -0500 Subject: [PATCH 230/436] making sure hidden patterns can still be included in other patterns --- src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php index bd628c0b..ce29545c 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php @@ -32,7 +32,7 @@ public function run() { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { + if ($patternStoreData["category"] == "pattern") { $nameDash = $patternStoreData["nameDash"]; $typeDash = $patternStoreData["typeDash"]; From 036fe702fb1e5ae34ab058ea2cb81d538b9c68ff Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 19 Jan 2016 15:46:07 -0500 Subject: [PATCH 231/436] Don't require very specific dependencies of upstream libraries --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 20be5945..6ec010cd 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ "prefer-stable": true, "require": { "php": ">=5.3.6", - "michelf/php-markdown": "1.5.0", - "seld/jsonlint": "1.3.1", - "symfony/event-dispatcher": "2.6.4", - "symfony/filesystem": "2.6.4", - "symfony/finder": "2.6.4", - "symfony/yaml": "2.6.4", - "kevinlebrun/colors.php": "0.4.1", + "michelf/php-markdown": "~1.5", + "seld/jsonlint": "~1.3", + "symfony/event-dispatcher": "~2.6", + "symfony/filesystem": "~2.6.4", + "symfony/finder": "~2.6", + "symfony/yaml": "~2.6", + "kevinlebrun/colors.php": "~0.4.1", "pattern-lab/unified-asset-installer": "~0.5", - "alchemy/zippy": "0.2.1" + "alchemy/zippy": "~0.2.1" } } From e7f54a79180b27bd0da43fe7dbfa9a5f076ad382 Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Mon, 28 Mar 2016 17:12:15 +0300 Subject: [PATCH 232/436] Fix fetchStarterKit directory issue --- src/PatternLab/Fetch.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 4bc6ceaf..da6c2654 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -55,15 +55,15 @@ public function fetchStarterKit($starterkit = "") { Console::writeError("please provide a path for the starterkit before trying to fetch it..."); } + // figure out the options for the GH path + list($org,$repo,$tag) = $this->getPackageInfo($starterkit); + // set default attributes $sourceDir = Config::getOption("sourceDir"); $tempDir = sys_get_temp_dir().DIRECTORY_SEPARATOR."pl-sk"; $tempDirSK = $tempDir.DIRECTORY_SEPARATOR."pl-sk-archive"; - $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist"; - $tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR."composer.json"; - - // figure out the options for the GH path - list($org,$repo,$tag) = $this->getPackageInfo($starterkit); + $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR.$repo."-".$tag.DIRECTORY_SEPARATOR."dist"; + $tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR.$repo."-".$tag.DIRECTORY_SEPARATOR."composer.json"; //get the path to the GH repo and validate it $tarballUrl = "https://github.com/".$org."/".$repo."/archive/".$tag.".tar.gz"; @@ -129,7 +129,7 @@ public function fetchStarterKit($starterkit = "") { Console::writeInfo("cleaning up the temp files..."); $fs = new Filesystem(); $fs->remove($tempFile); - $fs->remove($tempDir); + $fs->remove($tempDirSK); Console::writeInfo("the starterkit installation is complete..."); From b1db0873b1b7a6f55e7c2528d06ec96148ed4697 Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Tue, 29 Mar 2016 02:48:06 +0300 Subject: [PATCH 233/436] Revert unnecessary change --- src/PatternLab/Fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index da6c2654..f324f761 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -129,7 +129,7 @@ public function fetchStarterKit($starterkit = "") { Console::writeInfo("cleaning up the temp files..."); $fs = new Filesystem(); $fs->remove($tempFile); - $fs->remove($tempDirSK); + $fs->remove($tempDir); Console::writeInfo("the starterkit installation is complete..."); From 5163f537db814ea3f875d6281cea8888fc22e046 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 18 Apr 2016 09:59:21 -0400 Subject: [PATCH 234/436] using array_replace_recursive() instead of array_merge() --- src/PatternLab/Data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index d0b69956..732d295d 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -305,7 +305,7 @@ public static function getPatternSpecificData($patternPartial,$extraData = array if (isset($d["patternSpecific"]) && array_key_exists($patternPartial,$d["patternSpecific"])) { if (!empty($d["patternSpecific"][$patternPartial]["data"])) { - $d = array_merge($d, $d["patternSpecific"][$patternPartial]["data"]); + $d = array_replace_recursive($d, $d["patternSpecific"][$patternPartial]["data"]); } if (!empty($d["patternSpecific"][$patternPartial]["listItems"])) { @@ -317,7 +317,7 @@ public static function getPatternSpecificData($patternPartial,$extraData = array while ($k < $c) { $section = $numbers[$k]; - $d["listItems"][$section] = array_merge( $d["listItems"][$section], $d["patternSpecific"][$patternPartial]["listItems"][$section]); + $d["listItems"][$section] = array_replace_recursive( $d["listItems"][$section], $d["patternSpecific"][$patternPartial]["listItems"][$section]); $k++; } From 51729e200eaaf15e9d01c70384fed44d2ff8e22d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 18 Apr 2016 10:00:21 -0400 Subject: [PATCH 235/436] small fix to help with setting a pattern substore value --- src/PatternLab/PatternData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 3e18102a..d19962cb 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -478,7 +478,7 @@ public static function setPatternSubOption($patternStoreKey,$optionName,$pattern if (isset(self::$store[$patternStoreKey]) && isset(self::$store[$patternStoreKey][$optionName]) && isset(self::$store[$patternStoreKey][$optionName][$patternSubStoreKey])) { - self::$store[$patternStoreKey][$optionName][$patternLineageKey][$optionSubName] = $optionSubValue; + self::$store[$patternStoreKey][$optionName][$patternSubStoreKey][$optionSubName] = $optionSubValue; return true; } From 22550c86117dbde320162dab3a420f171fb6aba3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 18 Apr 2016 10:04:38 -0400 Subject: [PATCH 236/436] updating some back-end code to better handle new panel javascript --- .../Exporters/PatternPartialsExporter.php | 16 ++++++++++++++-- .../PatternData/Helpers/PatternCodeHelper.php | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 407eefe9..7e4eebd7 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -67,6 +67,20 @@ public function run($type = "", $subtype = "") { //$patternPartialData["patternCSSExists"] = Config::$options["enableCSS"]; $patternPartialData["patternCSSExists"] = false; + // add the pattern data so it can be exported + $patternData = array(); + //$patternFooterData["patternFooterData"]["cssEnabled"] = (Config::$options["enableCSS"] && isset($this->patternCSS[$p])) ? "true" : "false"; + $patternData["cssEnabled"] = false; + $patternData["lineage"] = isset($patternStoreData["lineages"]) ? $patternStoreData["lineages"] : array(); + $patternData["lineageR"] = isset($patternStoreData["lineagesR"]) ? $patternStoreData["lineagesR"] : array(); + $patternData["patternBreadcrumb"] = $patternStoreData["breadcrumb"]; + $patternData["patternDesc"] = (isset($patternStoreData["desc"])) ? $patternStoreData["desc"] : ""; + $patternData["patternExtension"] = ".mustache"; + $patternData["patternName"] = $patternStoreData["nameClean"]; + $patternData["patternPartial"] = $patternStoreData["partial"]; + $patternData["patternState"] = $patternStoreData["state"]; + $patternPartialData["patternData"] = json_encode($patternData); + $patternPartials[] = $patternPartialData; } @@ -80,5 +94,3 @@ public function run($type = "", $subtype = "") { } } - - diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 58048669..5b5c2cd1 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -81,7 +81,7 @@ public function run() { // set a default var $exportClean = (isset($options["exportClean"])) ? $options["exportClean"] : false; $data["patternLabHead"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $data["cacheBuster"]))) : ""; - $data["patternLabFoot"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "patternData" => json_encode($patternData)))) : ""; + $data["patternLabFoot"] = (!$this->exportFiles) ? $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $data["cacheBuster"], "isPattern" => true, "patternData" => json_encode($patternData)))) : ""; if (isset($patternStoreData["patternRaw"])) { From 174ab7474e7641846f16c3790cb10459462cd349 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 18 Apr 2016 17:22:54 -0700 Subject: [PATCH 237/436] Adding a Saying Cool! --- src/PatternLab/Generator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index 5817d2eb..6408fac7 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -212,7 +212,8 @@ public function printSaying() { "¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>", "@}~}~~~", "(>'.')> (>'.')> (>'.')> ", - "\(^-^)/" + "\(^-^)/", + "you've been at this awhile; perhaps it's time for a walk outside?" ); if (isset($sayings[$randomNumber])) { Console::writeLine("<".$color.">".$sayings[$randomNumber]."..."); From d383378a357346a16bf743dd40e03ca7a9546efe Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Thu, 21 Apr 2016 18:22:31 +0300 Subject: [PATCH 238/436] Cross-platform fix --- src/PatternLab/Fetch.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 430c80a9..375b4dea 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -99,7 +99,11 @@ public function fetchStarterKit($starterkit = "") { $zippy = Zippy::load(); $zippy->addStrategy(new UnpackFileStrategy()); $zippy->getAdapterFor('tar.gz')->open($tempFile)->extract($tempDirSK); - + + if (!is_dir($tempDirDist)) { + // try without repo dir + $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist"; + } // thrown an error if temp/dist/ doesn't exist if (!is_dir($tempDirDist)) { Console::writeError("the starterkit needs to contain a dist/ directory before it can be installed..."); From 72d239bf2dd4bac56721e809a3601301afb99aea Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Fri, 29 Apr 2016 12:05:08 -0700 Subject: [PATCH 239/436] removing null $options being passed to $fs->mirror() when sourceDir is not empty --- src/PatternLab/Fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 375b4dea..1d5a2ccb 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -203,7 +203,7 @@ protected function mirrorDist($sourceDir, $tempDirDist) { // mirror dist to source Console::writeInfo("installing the starterkit files..."); $fs = new Filesystem(); - $fs->mirror($tempDirDist, $sourceDir, null, $options); + $fs->mirror($tempDirDist, $sourceDir, null); Console::writeInfo("starterkit files have been installed..."); } From 0cf66258098b3e8f24e22f00f7cc878041ad2e5d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 15:00:00 -0400 Subject: [PATCH 240/436] initial fixes to support new install process --- src/PatternLab/InstallerUtil.php | 259 +++++++++++++++---------------- 1 file changed, 122 insertions(+), 137 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 059c1249..eaa01c51 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -48,20 +48,46 @@ protected static function buildFileList($initialList) { * Common init sequence */ protected static function init() { - + // start the timer Timer::start(); - + // initialize the console to print out any issues Console::init(); - + // initialize the config for the pluginDir $baseDir = __DIR__."/../../../../../"; Config::init($baseDir,false); - + + // make sure the source dir is set-up + $sourceDir = Config::getOption("sourceDir"); + if (!is_dir($sourceDir)) { + mkdir($sourceDir); + } + Dispatcher::init(); } + + /** + * Include StarterKit in an array_filter + */ + public static function includeStarterKit($var) { + + $result = ($var["type"] == "patternlab-starterkit"); + return $result; + + } + + /** + * Exclude StarterKit in an array_filter + */ + public static function excludeStarterKit($var) { + + $result = ($var["type"] != "patternlab-starterkit"); + return $result; + + } /** * Parse the component types to figure out what needs to be moved and added to the component JSON files @@ -388,123 +414,29 @@ protected static function pathExists($packageName,$path) { return false; } - + /** - * Run the PL tasks when a package is installed + * Run the PL tasks when Composer runs an install command + * @param {Array} collected package info * @param {Object} a script event object from composer */ - public static function postPackageInstall($event) { - - // run the console and config inits - self::init(); - - // run the tasks based on what's in the extra dir - self::runTasks($event,"install"); - + public static function postInstallCmd($installerInfo, $event) { + + self::runTasks($installerInfo); + } - + /** - * Run the PL tasks when a package is updated + * Run the PL tasks when Composer runs an update command + * @param {Array} collected package info * @param {Object} a script event object from composer */ - public static function postPackageUpdate($event) { - - // run the console and config inits - self::init(); - - self::runTasks($event,"update"); - + public static function postUpdateCmd($installerInfo, $event) { + + self::runTasks($installerInfo); + } - - /** - * Ask questions after the create package is done - * @param {Object} a script event object from composer - */ - public static function postCreateProjectCmd($event) { - - // see if there is an extra component - $extra = $event->getComposer()->getPackage()->getExtra(); - - if (isset($extra["patternlab"])) { - - self::init(); - Console::writeLine(""); - - // see if we have any starterkits to suggest - if (isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) { - - $suggestions = $extra["patternlab"]["starterKitSuggestions"]; - - // suggest starterkits - Console::writeInfo("suggested starterkits that work with this edition:", false, true); - foreach ($suggestions as $i => $suggestion) { - - // write each suggestion - $num = $i + 1; - Console::writeLine($num.": ".$suggestion, true); - - } - - // prompt for input on the suggestions - Console::writeLine(""); - $prompt = "choose an option or hit return to skip:"; - $options = "(ex. 1)"; - $input = Console::promptInput($prompt,$options); - $result = (int)$input - 1; - - if (isset($suggestions[$result])) { - - Console::writeLine(""); - $f = new Fetch(); - $result = $f->fetchStarterKit($suggestions[$result]); - - if ($result) { - - Console::writeLine(""); - $g = new Generator(); - $g->generate(array("foo" => "bar")); - - Console::writeLine(""); - Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); - - } - - } else { - - Console::writeWarning("you will need to install a StarterKit before using Pattern Lab..."); - - } - - } - - } - - } - - /** - * Make sure certain things are set-up before running the installation of a package - * @param {Object} a script event object from composer - */ - public static function preInstallCmd($event) { - - // run the console and config inits - self::init(); - - // default vars - $sourceDir = Config::getOption("sourceDir"); - $packagesDir = Config::getOption("packagesDir"); - - // check directories - if (!is_dir($sourceDir)) { - mkdir($sourceDir); - } - - if (!is_dir($packagesDir)) { - mkdir($packagesDir); - } - - } - + /** * Make sure pattern engines and listeners are removed on uninstall * @param {Object} a script event object from composer @@ -518,7 +450,7 @@ public static function prePackageUninstallCmd($event) { $package = $event->getOperation()->getPackage(); $type = $package->getType(); $name = $package->getName(); - $pathBase = Config::getOption("packagesDir")."/".$name; + $pathBase = $package->getTargetDir(); // see if the package has a listener and remove it self::scanForListener($pathBase,true); @@ -531,6 +463,50 @@ public static function prePackageUninstallCmd($event) { // go over .json in patternlab-components/, remove references to packagename } + + /** + * Prompt the user to install a starterkit + * @param {Array} the starterkit suggestions + */ + protected static function promptStarterKitInstall($starterKitSuggestions) { + + Console::writeLine(""); + + // suggest starterkits + Console::writeInfo("suggested starterkits that work with this edition:", false, true); + foreach ($starterKitSuggestions as $i => $suggestion) { + $num = $i + 1; + Console::writeLine($num.": ".$suggestion, true); + } + + // prompt for input on the suggestions + Console::writeLine(""); + + $prompt = "choose an option or hit return to skip:"; + $options = "(ex. 1)"; + $input = Console::promptInput($prompt,$options); + $result = (int)$input - 1; + + if (isset($starterKitSuggestions[$result])) { + + Console::writeLine(""); + $f = new Fetch(); + $result = $f->fetchStarterKit($suggestions[$result]); + + if ($result) { + + Console::writeLine(""); + $g = new Generator(); + $g->generate(array("foo" => "bar")); + + Console::writeLine(""); + Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); + + } + + } + + } /** * Remove dots from the path to make sure there is no file system traversal when looking for or writing files @@ -550,30 +526,39 @@ protected static function removeDots($path) { /** * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file - * @param {Object} a script event object from composer - * @param {String} the type of event starting the runTasks command + * @param {Array} the info culled from installing various pattern lab-related packages */ - protected static function runTasks($event,$type) { - - // get package info - $package = ($type == "install") ? $event->getOperation()->getPackage() : $event->getOperation()->getTargetPackage(); - $extra = $package->getExtra(); - $type = $package->getType(); - $name = $package->getName(); - $pathBase = Config::getOption("packagesDir")."/".$name; - $pathDist = $pathBase."/dist/"; - - // make sure we're only evaluating pattern lab packages - if (strpos($type,"patternlab-") !== false) { - + protected static function runTasks($installerInfo) { + + // initialize a bunch of stuff like config and console + self::init(); + + // make sure user is prompted to install starterkit + if (!empty($installerInfo["starterKitSuggestions"])) { + self::promptStarterKitInstall($installerInfo["starterKitSuggestions"]); + } + + // reorder packages so the starterkit is first if it's being installed as a package + $packages = $installerInfo["packages"]; + $packages = array_merge(array_filter($packages, "self::includeStarterKit"), array_filter($packages, "self::excludeStarterKit")); + + foreach ($packages as $package) { + + // set-up package info + $extra = $package["extra"]; + $type = $package["type"]; + $name = $package["name"]; + $pathBase = $package["pathBase"]; + $pathDist = $package["pathDist"]; + // make sure that it has the name-spaced section of data to be parsed. if it exists parse it - if (isset($extra["patternlab"])) { - self::parseComposerExtraList($extra["patternlab"], $name, $pathDist); + if (!empty($extra)) { + self::parseComposerExtraList($extra, $name, $pathDist); } - + // see if the package has a listener self::scanForListener($pathBase); - + // address other specific needs based on type if ($type == "patternlab-patternengine") { self::scanForPatternEngineRule($pathBase); @@ -582,9 +567,9 @@ protected static function runTasks($event,$type) { } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { Config::updateConfigOption("styleguideKit",$name); } - + } - + } /** @@ -594,7 +579,7 @@ protected static function runTasks($event,$type) { protected static function scanForListener($pathPackage,$remove = false) { // get listener list path - $pathList = Config::getOption("packagesDir")."/listeners.json"; + $pathList = Config::getOption("configDir")."/listeners.json"; // make sure listeners.json exists. if not create it if (!file_exists($pathList)) { @@ -637,7 +622,7 @@ protected static function scanForListener($pathPackage,$remove = false) { protected static function scanForPatternEngineRule($pathPackage,$remove = false) { // get listener list path - $pathList = Config::getOption("packagesDir")."/patternengines.json"; + $pathList = Config::getOption("configDir")."/patternengines.json"; // make sure patternengines.json exists. if not create it if (!file_exists($pathList)) { From 673c006079651c6fc19bb49c824b6196ee5a04ad Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 15:07:20 -0400 Subject: [PATCH 241/436] fixing whitespace --- src/PatternLab/InstallerUtil.php | 216 +++++++++++++++---------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index eaa01c51..dfabe018 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -20,7 +20,7 @@ use \Symfony\Component\Finder\Finder; class InstallerUtil { - + /** * Move the component files from the package to their location in the patternlab-components dir * @param {String/Array} the items to create a fileList for @@ -28,9 +28,9 @@ class InstallerUtil { * @return {Array} list of files destination and source */ protected static function buildFileList($initialList) { - + $fileList = array(); - + // see if it's an array. loop over the multiple items if it is if (is_array($initialList)) { foreach ($initialList as $listItem) { @@ -39,11 +39,11 @@ protected static function buildFileList($initialList) { } else { $fileList[$listItem] = $listItem; } - + return $fileList; - + } - + /** * Common init sequence */ @@ -66,7 +66,7 @@ protected static function init() { } Dispatcher::init(); - + } /** @@ -88,7 +88,7 @@ public static function excludeStarterKit($var) { return $result; } - + /** * Parse the component types to figure out what needs to be moved and added to the component JSON files * @param {String} file path to move @@ -99,25 +99,25 @@ public static function excludeStarterKit($var) { * @param {Array} the list of files to be moved */ protected static function moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase) { - + $fs = new Filesystem(); - + // make sure the destination base exists if (!is_dir($destinationBase)) { $fs->mkdir($destinationBase); } - + // clean any * or / on the end of $destination $destination = (($destination != "*") && ($destination[strlen($destination)-1] == "*")) ? substr($destination,0,-1) : $destination; $destination = ($destination[strlen($destination)-1] == "/") ? substr($destination,0,-1) : $destination; - + // decide how to move the files. the rules: // src ~ dest -> action // * ~ * -> mirror all in {srcroot}/ to {destroot}/ // * ~ path/* -> mirror all in {srcroot}/ to {destroot}/path/ // foo/* ~ path/* -> mirror all in {srcroot}/foo/ to {destroot}/path/ // foo/s.html ~ path/k.html -> mirror {srcroot}/foo/s.html to {destroot}/path/k.html - + if (($source == "*") && ($destination == "*")) { $result = self::pathExists($packageName, $destinationBase.DIRECTORY_SEPARATOR); $options = ($result) ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); @@ -142,40 +142,40 @@ protected static function moveFiles($source,$destination,$packageName,$sourceBas $override = ($result) ? true : false; $fs->copy($sourceBase.$source, $destinationBase.DIRECTORY_SEPARATOR.$destination, $override); } - + } - + /** * Parse the extra section from composer.json * @param {Object} the JSON for the composer extra section */ public static function parseComposerExtraList($composerExtra, $name, $pathDist) { - + // move assets to the base directory if (isset($composerExtra["dist"]["baseDir"])) { self::parseFileList($name,$pathDist,Config::getOption("baseDir"),$composerExtra["dist"]["baseDir"]); } - + // move assets to the public directory if (isset($composerExtra["dist"]["publicDir"])) { self::parseFileList($name,$pathDist,Config::getOption("publicDir"),$composerExtra["dist"]["publicDir"]); } - + // move assets to the source directory if (isset($composerExtra["dist"]["sourceDir"])) { self::parseFileList($name,$pathDist,Config::getOption("sourceDir"),$composerExtra["dist"]["sourceDir"]); } - + // move assets to the scripts directory if (isset($composerExtra["dist"]["scriptsDir"])) { self::parseFileList($name,$pathDist,Config::getOption("scriptsDir"),$composerExtra["dist"]["scriptsDir"]); } - + // move assets to the data directory if (isset($composerExtra["dist"]["dataDir"])) { self::parseFileList($name,$pathDist,Config::getOption("dataDir"),$composerExtra["dist"]["dataDir"]); } - + // move assets to the components directory if (isset($composerExtra["dist"]["componentDir"])) { $templateExtension = isset($composerExtra["templateExtension"]) ? $composerExtra["templateExtension"] : "mustache"; @@ -185,21 +185,21 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) self::parseComponentList($name,$pathDist,$componentDir."/".$name,$composerExtra["dist"]["componentDir"],$templateExtension,$onready,$callback); self::parseFileList($name,$pathDist,$componentDir."/".$name,$composerExtra["dist"]["componentDir"]); } - + // see if we need to modify the config if (isset($composerExtra["config"])) { - + foreach ($composerExtra["config"] as $option => $value) { - + // update the config option Config::updateConfigOption($option,$value); - + } - + } - + } - + /** * Parse the component types to figure out what needs to be added to the component JSON files * @param {String} the name of the package @@ -211,7 +211,7 @@ public static function parseComposerExtraList($composerExtra, $name, $pathDist) * @param {String} the javascript to run as a callback */ protected static function parseComponentList($packageName,$sourceBase,$destinationBase,$componentFileList,$templateExtension,$onready,$callback) { - + /* iterate over a source or source dirs and copy files into the componentdir. use file extensions to add them to the appropriate type arrays below. so... @@ -226,40 +226,40 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati "templateExtension": "" } } - + */ - + // decide how to type list files. the rules: // src ~ dest -> action // * ~ * -> iterate over all files in {srcroot}/ and create a type listing // foo/* ~ path/* -> iterate over all files in {srcroot}/foo/ and create a type listing // foo/s.html ~ path/k.html -> create a type listing for {srcroot}/foo/s.html - + // set-up component types store $componentTypes = array("stylesheets" => array(), "javascripts" => array(), "templates" => array()); - + // iterate over the file list foreach ($componentFileList as $componentItem) { - + // retrieve the source & destination $source = self::removeDots(key($componentItem)); $destination = self::removeDots($componentItem[$source]); - + if (($source == "*") || ($source[strlen($source)-1] == "*")) { - + // build the source & destination $source = (strlen($source) > 2) ? rtrim($source,"/*") : ""; $destination = (strlen($destination) > 2) ? rtrim($destination,"/*") : ""; - + // get files $finder = new Finder(); $finder->files()->in($sourceBase.$source); - + // iterate over the returned objects foreach ($finder as $file) { - + $ext = $file->getExtension(); - + if ($ext == "css") { $componentTypes["stylesheets"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); } else if ($ext == "js") { @@ -267,17 +267,17 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati } else if ($ext == $templateExtension) { $componentTypes["templates"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); } - + } - + } else { - + $bits = explode(".",$source); - + if (count($bits) > 0) { - + $ext = $bits[count($bits)-1]; - + if ($ext == "css") { $componentTypes["stylesheets"][] = $destination; } else if ($ext == "js") { @@ -285,13 +285,13 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati } else if ($ext == $templateExtension) { $componentTypes["templates"][] = $destination; } - + } - + } - + } - + /* FOR USE AS A PACKAGE TO BE LOADED LATER { @@ -315,21 +315,21 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati $packageInfo["onready"] = $onready; $packageInfo["callback"] = $callback; $packageInfoPath = Config::getOption("componentDir")."/packages/".str_replace("/","-",$packageName).".json"; - + // double-check the dirs are created if (!is_dir(Config::getOption("componentDir"))) { mkdir(Config::getOption("componentDir")); } - + if (!is_dir(Config::getOption("componentDir")."/packages/")) { mkdir(Config::getOption("componentDir")."/packages/"); } - + // write out the package info file_put_contents($packageInfoPath,json_encode($packageInfo)); - + } - + /** * Move the files from the package to their location in the public dir or source dir * @param {String} the name of the package @@ -338,20 +338,20 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati * @param {Array} the list of files to be moved */ protected static function parseFileList($packageName,$sourceBase,$destinationBase,$fileList) { - + foreach ($fileList as $fileItem) { - + // retrieve the source & destination $source = self::removeDots(key($fileItem)); $destination = self::removeDots($fileItem[$source]); - + // depending on the source handle things differently. mirror if it ends in /* self::moveFiles($source,$destination,$packageName,$sourceBase,$destinationBase); - + } - + } - + /** * Check to see if the path already exists. If it does prompt the user to double-check it should be overwritten * @param {String} the package name @@ -360,20 +360,20 @@ protected static function parseFileList($packageName,$sourceBase,$destinationBas * @return {Boolean} if the path exists and should be overwritten */ protected static function pathExists($packageName,$path) { - + $fs = new Filesystem; - + if ($fs->exists($path)) { - + // set-up a human readable prompt $humanReadablePath = str_replace(Config::getOption("baseDir"), "./", $path); - + // set if the prompt should fire $prompt = true; - + // are we checking a directory? if (is_dir($path)) { - + // see if the directory is essentially empty $files = scandir($path); foreach ($files as $key => $file) { @@ -383,20 +383,20 @@ protected static function pathExists($packageName,$path) { unset($files[$key]); } } - + if (empty($files)) { $prompt = false; } - + } - + if ($prompt) { - + // prompt for input using the supplied query $prompt = "the path ".$humanReadablePath." already exists. merge or replace with the contents of ".$packageName." package?"; $options = "M/r"; $input = Console::promptInput($prompt,$options); - + if ($input == "m") { Console::writeTag("ok","contents of ".$humanReadablePath." have been merged with the package's content...", false, true); return false; @@ -404,15 +404,15 @@ protected static function pathExists($packageName,$path) { Console::writeWarning("contents of ".$humanReadablePath." have been replaced by the package's content...", false, true); return true; } - + } - + return false; - + } - + return false; - + } /** @@ -442,26 +442,26 @@ public static function postUpdateCmd($installerInfo, $event) { * @param {Object} a script event object from composer */ public static function prePackageUninstallCmd($event) { - + // run the console and config inits self::init(); - + // get package info $package = $event->getOperation()->getPackage(); $type = $package->getType(); $name = $package->getName(); $pathBase = $package->getTargetDir(); - + // see if the package has a listener and remove it self::scanForListener($pathBase,true); - + // see if the package is a pattern engine and remove the rule if ($type == "patternlab-patternengine") { self::scanForPatternEngineRule($pathBase,true); } - + // go over .json in patternlab-components/, remove references to packagename - + } /** @@ -507,7 +507,7 @@ protected static function promptStarterKitInstall($starterKitSuggestions) { } } - + /** * Remove dots from the path to make sure there is no file system traversal when looking for or writing files * @param {String} the path to check and remove dots @@ -523,7 +523,7 @@ protected static function removeDots($path) { } return implode("/", $parts); } - + /** * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file * @param {Array} the info culled from installing various pattern lab-related packages @@ -571,35 +571,35 @@ protected static function runTasks($installerInfo) { } } - + /** * Scan the package for a listener * @param {String} the path for the package */ protected static function scanForListener($pathPackage,$remove = false) { - + // get listener list path $pathList = Config::getOption("configDir")."/listeners.json"; - + // make sure listeners.json exists. if not create it if (!file_exists($pathList)) { file_put_contents($pathList, "{ \"listeners\": [ ] }"); } - + // load listener list $listenerList = json_decode(file_get_contents($pathList),true); - + // set-up a finder to find the listener $finder = new Finder(); $finder->files()->name('PatternLabListener.php')->in($pathPackage); - + // iterate over the returned objects foreach ($finder as $file) { - + // create the name $dirs = explode(DIRECTORY_SEPARATOR,$file->getPath()); $listenerName = "\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); - + // check to see what we should do with the listener info if (!$remove && !in_array($listenerName,$listenerList["listeners"])) { $listenerList["listeners"][] = $listenerName; @@ -607,42 +607,42 @@ protected static function scanForListener($pathPackage,$remove = false) { $key = array_search($listenerName, $listenerList["listeners"]); unset($listenerList["listeners"][$key]); } - + // write out the listener list file_put_contents($pathList,json_encode($listenerList)); - + } - + } - + /** * Scan the package for a pattern engine rule * @param {String} the path for the package */ protected static function scanForPatternEngineRule($pathPackage,$remove = false) { - + // get listener list path $pathList = Config::getOption("configDir")."/patternengines.json"; - + // make sure patternengines.json exists. if not create it if (!file_exists($pathList)) { file_put_contents($pathList, "{ \"patternengines\": [ ] }"); } - + // load pattern engine list $patternEngineList = json_decode(file_get_contents($pathList),true); - + // set-up a finder to find the pattern engine $finder = new Finder(); $finder->files()->name("PatternEngineRule.php")->in($pathPackage); - + // iterate over the returned objects foreach ($finder as $file) { - + /// create the name $dirs = explode(DIRECTORY_SEPARATOR,$file->getPath()); $patternEngineName = "\\".$dirs[count($dirs)-3]."\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); - + // check what we should do with the pattern engine info if (!$remove && !in_array($patternEngineName, $patternEngineList["patternengines"])) { $patternEngineList["patternengines"][] = $patternEngineName; @@ -650,12 +650,12 @@ protected static function scanForPatternEngineRule($pathPackage,$remove = false) $key = array_search($patternEngineName, $patternEngineList["patternengines"]); unset($patternEngineList["patternengines"][$key]); } - + // write out the pattern engine list file_put_contents($pathList,json_encode($patternEngineList)); - + } - + } - + } From 7fe8af22f5eb071c0418ab8ee90d7de103925766 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 15:42:08 -0400 Subject: [PATCH 242/436] PSR-4 support based on work by @bangpound --- src/PatternLab/InstallerUtil.php | 92 ++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index dfabe018..69ea8193 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -89,6 +89,88 @@ public static function excludeStarterKit($var) { } + /** + * Extract the classes in the given file. + * + * This method taken from Symfony ClassLoader component. + * + * @see \Symfony\Component\ClassLoader\ClassMapGenerator::findClasses() + * @license http://symfony.com/doc/current/contributing/code/license.html MIT license + * + * @param string $path The file to check + * + * @return array The found classes + */ + private static function findClasses($path) { + + $contents = file_get_contents($path); + $tokens = token_get_all($contents); + + $classes = array(); + + $namespace = ''; + for ($i = 0; isset($tokens[$i]); ++$i) { + $token = $tokens[$i]; + + if (!isset($token[1])) { + continue; + } + + $class = ''; + + switch ($token[0]) { + case T_NAMESPACE: + $namespace = ''; + // If there is a namespace, extract it + while (isset($tokens[++$i][1])) { + if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) { + $namespace .= $tokens[$i][1]; + } + } + $namespace .= '\\'; + break; + case T_CLASS: + case T_INTERFACE: + case T_TRAIT: + // Skip usage of ::class constant + $isClassConstant = false; + for ($j = $i - 1; $j > 0; --$j) { + if (!isset($tokens[$j][1])) { + break; + } + + if (T_DOUBLE_COLON === $tokens[$j][0]) { + $isClassConstant = true; + break; + } elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) { + break; + } + } + + if ($isClassConstant) { + break; + } + + // Find the classname + while (isset($tokens[++$i][1])) { + $t = $tokens[$i]; + if (T_STRING === $t[0]) { + $class .= $t[1]; + } elseif ('' !== $class && T_WHITESPACE === $t[0]) { + break; + } + } + + $classes[] = ltrim($namespace.$class, '\\'); + break; + default: + break; + } + } + + return $classes; + } + /** * Parse the component types to figure out what needs to be moved and added to the component JSON files * @param {String} file path to move @@ -597,8 +679,8 @@ protected static function scanForListener($pathPackage,$remove = false) { foreach ($finder as $file) { // create the name - $dirs = explode(DIRECTORY_SEPARATOR,$file->getPath()); - $listenerName = "\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); + $classes = self::findClasses($file->getPathname()); + $listenerName = "\\".$classes[0]; // check to see what we should do with the listener info if (!$remove && !in_array($listenerName,$listenerList["listeners"])) { @@ -639,9 +721,9 @@ protected static function scanForPatternEngineRule($pathPackage,$remove = false) // iterate over the returned objects foreach ($finder as $file) { - /// create the name - $dirs = explode(DIRECTORY_SEPARATOR,$file->getPath()); - $patternEngineName = "\\".$dirs[count($dirs)-3]."\\".$dirs[count($dirs)-2]."\\".$dirs[count($dirs)-1]."\\".str_replace(".php","",$file->getFilename()); + // create the name + $classes = self::findClasses($file->getPathname()); + $patternEngineName = "\\".$classes[0]; // check what we should do with the pattern engine info if (!$remove && !in_array($patternEngineName, $patternEngineList["patternengines"])) { From b0be3a2946083fdfa480d90c48581bc6a056da19 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 16:06:25 -0400 Subject: [PATCH 243/436] getting rid of refs to packagesDir in favor of configDir --- config/config.yml.default | 1 - src/PatternLab/Config.php | 13 ++++++------- src/PatternLab/Dispatcher.php | 11 +++-------- src/PatternLab/InstallerUtil.php | 1 + src/PatternLab/PatternEngine.php | 13 ++++--------- src/PatternLab/Template.php | 10 +++++----- 6 files changed, 19 insertions(+), 30 deletions(-) diff --git a/config/config.yml.default b/config/config.yml.default index 01c0bd48..b7094043 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -35,6 +35,5 @@ cacheBusterOn: "true" # project directories exportDir: "export" -packagesDir: "packages" publicDir: "public" sourceDir: "source" diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index f5886246..31832d3e 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -48,7 +48,7 @@ protected static function cleanDir($dir) { /** * Get the value associated with an option from the Config * @param {String} the name of the option to be checked - * + * * @return {String/Boolean} the value of the get or false if it wasn't found */ public static function getOption($optionName = "") { @@ -67,7 +67,7 @@ public static function getOption($optionName = "") { /** * Get the options set in the config - * + * * @return {Array} the options from the config */ public static function getOptions() { @@ -180,7 +180,6 @@ public static function init($baseDir = "", $verbose = true) { // set-up the various dirs self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; - self::$options["packagesDir"] = isset(self::$options["packagesDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["packagesDir"]) : self::$options["baseDir"]."packages"; self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts"; self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source"; @@ -214,7 +213,7 @@ public static function init($baseDir = "", $verbose = true) { /** * Check to see if the given array is an associative array * @param {Array} the array to be checked - * + * * @return {Boolean} whether it's an associative array */ protected static function isAssoc($array) { @@ -248,7 +247,7 @@ public static function loadOptions($data,$parentKey = "") { * Add an option and associated value to the base Config * @param {String} the name of the option to be added * @param {String} the value of the option to be added - * + * * @return {Boolean} whether the set was successful */ public static function setOption($optionName = "", $optionValue = "") { @@ -269,7 +268,7 @@ public static function setOption($optionName = "", $optionValue = "") { /** * Add an option to the exposedOptions array so it can be exposed on the front-end * @param {String} the name of the option to be added to the exposedOption arrays - * + * * @return {Boolean} whether the set was successful */ public static function setExposedOption($optionName = "") { @@ -337,7 +336,7 @@ public static function updateConfigOption($optionName,$optionValue) { * Update an option and associated value to the base Config * @param {String} the name of the option to be updated * @param {String} the value of the option to be updated - * + * * @return {Boolean} whether the update was successful */ public static function updateOption($optionName = "", $optionValue = "") { diff --git a/src/PatternLab/Dispatcher.php b/src/PatternLab/Dispatcher.php index f6b1ee84..c6305722 100644 --- a/src/PatternLab/Dispatcher.php +++ b/src/PatternLab/Dispatcher.php @@ -46,18 +46,13 @@ public static function init() { protected static function loadListeners() { // default var - $packagesDir = Config::getOption("packagesDir"); - - // see if the package dir exists. if it doesn't make it - if (!is_dir($packagesDir)) { - mkdir($packagesDir); - } + $configDir = Config::getOption("configDir"); // make sure the listener data exists - if (file_exists($packagesDir."/listeners.json")) { + if (file_exists($configDir."/listeners.json")) { // get listener list data - $listenerList = json_decode(file_get_contents($packagesDir."/listeners.json"), true); + $listenerList = json_decode(file_get_contents($configDir."/listeners.json"), true); // get the listener info foreach ($listenerList["listeners"] as $listenerName) { diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 69ea8193..43eb52d4 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -646,6 +646,7 @@ protected static function runTasks($installerInfo) { self::scanForPatternEngineRule($pathBase); } else if ($type == "patternlab-starterkit") { Config::updateConfigOption("starterKit",$name); + Config::updateConfigOption("starterKitPath",$pathBase); } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { Config::updateConfigOption("styleguideKit",$name); } diff --git a/src/PatternLab/PatternEngine.php b/src/PatternLab/PatternEngine.php index bd620773..163c7d6d 100644 --- a/src/PatternLab/PatternEngine.php +++ b/src/PatternLab/PatternEngine.php @@ -57,18 +57,13 @@ public static function init() { public static function loadRules() { // default var - $packagesDir = Config::getOption("packagesDir"); - - // see if the package dir exists. if it doesn't it means composer hasn't been run - if (!is_dir($packagesDir)) { - Console::writeError("you haven't fully set-up Pattern Lab yet. please add a pattern engine..."); - } + $configDir = Config::getOption("configDir"); // make sure the pattern engine data exists - if (file_exists($packagesDir."/patternengines.json")) { + if (file_exists($configDir."/patternengines.json")) { // get pattern engine list data - $patternEngineList = json_decode(file_get_contents($packagesDir."/patternengines.json"), true); + $patternEngineList = json_decode(file_get_contents($configDir."/patternengines.json"), true); // get the pattern engine info foreach ($patternEngineList["patternengines"] as $patternEngineName) { @@ -78,7 +73,7 @@ public static function loadRules() { } } else { - Console::writeError("The pattern engines list isn't available in ".$packagesDir."..."); + Console::writeError("The pattern engines list isn't available in ".$configDir."..."); } } diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index 0855a0bb..d17d03c6 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -6,7 +6,7 @@ * Copyright (c) 2014 Dave Olsen, http://dmolsen.com * Licensed under the MIT license * - * Set-ups the vars needed related to setting up and rendering templates. Meaning putting + * Set-ups the vars needed related to setting up and rendering templates. Meaning putting * */ @@ -42,12 +42,12 @@ public static function init() { // set-up config vars $patternExtension = Config::getOption("patternExtension"); - $pluginDir = Config::getOption("packagesDir"); $sourceDir = Config::getOption("sourceDir"); $styleguideKit = Config::getOption("styleguideKit"); + $styleguideKitPath = Config::getOption("styleguideKitPath"); // load pattern-lab's resources - $partialPath = $pluginDir."/".$styleguideKit."/views/partials"; + $partialPath = $styleguideKitPath."/views/partials"; self::$htmlHead = file_get_contents($partialPath."/general-header.".$patternExtension); self::$htmlFoot = file_get_contents($partialPath."/general-footer.".$patternExtension); @@ -62,8 +62,8 @@ public static function init() { $filesystemLoaderClass = $patternEngineBasePath."\Loaders\FilesystemLoader"; $options = array(); - $options["templatePath"] = $pluginDir."/".$styleguideKit."/views"; - $options["partialsPath"] = $pluginDir."/".$styleguideKit."/views/partials"; + $options["templatePath"] = $styleguideKitPath."/views"; + $options["partialsPath"] = $styleguideKitPath."/views/partials"; self::$filesystemLoader = new $filesystemLoaderClass($options); From e5e478382f179db27645751fa3fd9d5c467fc7fb Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 16:07:15 -0400 Subject: [PATCH 244/436] removing ref to unified asset installer since nothing needs to go in ./packages --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 20be5945..aa4bacef 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ "symfony/finder": "2.6.4", "symfony/yaml": "2.6.4", "kevinlebrun/colors.php": "0.4.1", - "pattern-lab/unified-asset-installer": "~0.5", "alchemy/zippy": "0.2.1" } } From 2ac6827a05040d8c4eaade5ab525aa6427b6e21c Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 5 May 2016 15:50:39 -0600 Subject: [PATCH 245/436] removing Mustache specific syntax from error code --- src/PatternLab/PatternData/Helpers/LineageHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 9f9a5648..daf1b577 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -61,7 +61,7 @@ public function run() { if (strpos($lineage, '/') === false) { $fileName = $patternStoreData["pathName"].".".$patternExtension; - Console::writeWarning("you may have a typo in ".$fileName.". {{> ".$lineage." }} is not a valid pattern..."); + Console::writeWarning("you may have a typo in ".$fileName.". `".$lineage."` is not a valid pattern..."); } } From a0dc8ecda6906f3fd190e07689291b840f8686bf Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 19:21:57 -0400 Subject: [PATCH 246/436] seeing what's in package --- src/PatternLab/InstallerUtil.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 43eb52d4..1837c07e 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -626,6 +626,8 @@ protected static function runTasks($installerInfo) { foreach ($packages as $package) { + print_r($package); + // set-up package info $extra = $package["extra"]; $type = $package["type"]; From 08a7f4e7acbf52d1ce196e7ad1b54a83826455bc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 19:26:39 -0400 Subject: [PATCH 247/436] adding configPath as a config option --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 31832d3e..4f8c6e66 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -178,6 +178,7 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs + self::$options["configDir"] = self::$userConfigPath; self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; From 634d3fa9e8e92ce0e5e9bca5492c368c9c1d4fa4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 19:36:50 -0400 Subject: [PATCH 248/436] adding a configDir option --- src/PatternLab/Config.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 4f8c6e66..c10bae3d 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -97,22 +97,16 @@ public static function init($baseDir = "", $verbose = true) { // set the baseDir option self::$options["baseDir"] = ($baseDir[strlen($baseDir)-1] == DIRECTORY_SEPARATOR) ? $baseDir : $baseDir.DIRECTORY_SEPARATOR; + // set-up the paths + self::$userConfigDirClean = self::$options["baseDir"].self::$userConfigDirClean; + self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; + self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; + self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; + self::$plConfigPath = self::$options["baseDir"]."vendor/pattern-lab/core/".self::$plConfigPath; + // can't add __DIR__ above so adding here - if (!self::$dirAdded) { - - // set-up the paths - self::$userConfigDirClean = self::$options["baseDir"].self::$userConfigDirClean; - self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; - self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; - self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; - self::$plConfigPath = self::$options["baseDir"]."vendor/pattern-lab/core/".self::$plConfigPath; - self::$dirAdded = true; - - // just in case the config directory doesn't exist at all - if (!is_dir(self::$userConfigDir)) { - mkdir(self::$userConfigDir); - } - + if (!is_dir(self::$userConfigDir)) { + mkdir(self::$userConfigDir); } // make sure migrate doesn't happen by default From c55fcee3d3e1ff79af8b06ca8dee1512af84cf08 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 19:40:04 -0400 Subject: [PATCH 249/436] using configdir instead of configpath >.< --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index c10bae3d..a83002c9 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -172,7 +172,7 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs - self::$options["configDir"] = self::$userConfigPath; + self::$options["configDir"] = self::$userConfigDir; self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; From db353f5ba57a9e044db06b14c91d87e59c5882a0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 19:47:33 -0400 Subject: [PATCH 250/436] removing a debug line --- src/PatternLab/InstallerUtil.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 1837c07e..43eb52d4 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -626,8 +626,6 @@ protected static function runTasks($installerInfo) { foreach ($packages as $package) { - print_r($package); - // set-up package info $extra = $package["extra"]; $type = $package["type"]; From 530236a1bc2bf3e1281bb9eb854910cb4c8da033 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 20:09:33 -0400 Subject: [PATCH 251/436] double-checking how the starterkit is handled --- src/PatternLab/InstallerUtil.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 43eb52d4..a79167ac 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -622,8 +622,13 @@ protected static function runTasks($installerInfo) { // reorder packages so the starterkit is first if it's being installed as a package $packages = $installerInfo["packages"]; + + print_r($packages); + $packages = array_merge(array_filter($packages, "self::includeStarterKit"), array_filter($packages, "self::excludeStarterKit")); + print_r($packages); + foreach ($packages as $package) { // set-up package info From 2f40745bfd0dfe276576fcd39292918b00efd72b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 5 May 2016 20:15:05 -0400 Subject: [PATCH 252/436] removing a sanity check for how packages are reordered --- src/PatternLab/InstallerUtil.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index a79167ac..43eb52d4 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -622,13 +622,8 @@ protected static function runTasks($installerInfo) { // reorder packages so the starterkit is first if it's being installed as a package $packages = $installerInfo["packages"]; - - print_r($packages); - $packages = array_merge(array_filter($packages, "self::includeStarterKit"), array_filter($packages, "self::excludeStarterKit")); - print_r($packages); - foreach ($packages as $package) { // set-up package info From 132cb86fe6d6e2a06bc89ee34a9024ed71625e9e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 09:42:15 -0400 Subject: [PATCH 253/436] add a 'force update' option --- src/PatternLab/Config.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index a83002c9..0c515678 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -283,8 +283,9 @@ public static function setExposedOption($optionName = "") { * Update a single config option based on a change in composer.json * @param {String} the name of the option to be changed * @param {String} the new value of the option to be changed + * @param {Boolean} whether to force the update of the option */ - public static function updateConfigOption($optionName,$optionValue) { + public static function updateConfigOption($optionName,$optionValue, $force = false) { if (is_string($optionValue) && strpos($optionValue,"") !== false) { @@ -296,7 +297,7 @@ public static function updateConfigOption($optionName,$optionValue) { self::writeUpdateConfigOption($optionName,$input); Console::writeTag("ok","config option ".$optionName." updated...", false, true); - } else if (!isset(self::$options[$optionName]) || (self::$options["overrideConfig"] == "a")) { + } else if (!isset(self::$options[$optionName]) || (self::$options["overrideConfig"] == "a") || $force) { // if the option isn't set or the config is always to override update the config self::writeUpdateConfigOption($optionName,$optionValue); From bab96a8427d5c1e680d2cfdc6f072d5dfb0b47f4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 09:42:37 -0400 Subject: [PATCH 254/436] allowing for config overrides from the edition composer.json --- src/PatternLab/InstallerUtil.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 43eb52d4..411d2aee 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -651,6 +651,13 @@ protected static function runTasks($installerInfo) { Config::updateConfigOption("styleguideKit",$name); } + // override any configs that have been set-up + if (!empty($installerInfo["configOverrides"])) { + foreach ($installerInfo["configOverrides"] as $option => $value) { + Config::updateConfigOption($option,$value, true); // forces the update + } + } + } } From 8559496af7a00036c441884c9de46014d3abdc5f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 09:54:09 -0400 Subject: [PATCH 255/436] moving the 'hey, i've been installed' behind a create-project set flag --- src/PatternLab/InstallerUtil.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 411d2aee..ac90baf6 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -575,17 +575,6 @@ protected static function promptStarterKitInstall($starterKitSuggestions) { $f = new Fetch(); $result = $f->fetchStarterKit($suggestions[$result]); - if ($result) { - - Console::writeLine(""); - $g = new Generator(); - $g->generate(array("foo" => "bar")); - - Console::writeLine(""); - Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); - - } - } } @@ -660,6 +649,17 @@ protected static function runTasks($installerInfo) { } + if ($installerInfo["projectInstall"]) { + + Console::writeLine(""); + $g = new Generator(); + $g->generate(array("foo" => "bar")); + + Console::writeLine(""); + Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); + + } + } /** From 28ff4ba84e5cd1648770610ce6ffad811c298bc3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 10:03:29 -0400 Subject: [PATCH 256/436] adding styleguideKitPath --- src/PatternLab/InstallerUtil.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index ac90baf6..f918af44 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -638,6 +638,7 @@ protected static function runTasks($installerInfo) { Config::updateConfigOption("starterKitPath",$pathBase); } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { Config::updateConfigOption("styleguideKit",$name); + Config::updateConfigOption("styleguideKitPath",$pathBase); } // override any configs that have been set-up From 8b76cc9ea521269367757e930bf3c9a405368207 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 10:20:06 -0400 Subject: [PATCH 257/436] add a method to reload options after writing the option to disk --- src/PatternLab/Config.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 0c515678..1865a73f 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -376,6 +376,9 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { $options[$optionName] = $optionValue; } + // reload the options + self::loadOptions($options); + // dump the YAML $configOutput = Yaml::dump($options, 3); From 004cf1e1455d5ede8f857b20d9581989b859e709 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 10:28:08 -0400 Subject: [PATCH 258/436] moving config override to the correct location --- src/PatternLab/InstallerUtil.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index f918af44..15132d9b 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -641,13 +641,13 @@ protected static function runTasks($installerInfo) { Config::updateConfigOption("styleguideKitPath",$pathBase); } - // override any configs that have been set-up - if (!empty($installerInfo["configOverrides"])) { - foreach ($installerInfo["configOverrides"] as $option => $value) { - Config::updateConfigOption($option,$value, true); // forces the update - } + } + + // override any configs that have been set-up + if (!empty($installerInfo["configOverrides"])) { + foreach ($installerInfo["configOverrides"] as $option => $value) { + Config::updateConfigOption($option,$value, true); // forces the update } - } if ($installerInfo["projectInstall"]) { From b2143967dec22b98922fbdf34ea25a72b251a87c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 10:33:05 -0400 Subject: [PATCH 259/436] adding debug statement --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 1865a73f..6bf8035c 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -377,6 +377,7 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { } // reload the options + print "trying to load options"; self::loadOptions($options); // dump the YAML From b0ba4e59f45876178d9ea767f85962ceb197bcf4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 11:01:06 -0400 Subject: [PATCH 260/436] removing debug statement --- src/PatternLab/Config.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 6bf8035c..1865a73f 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -377,7 +377,6 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { } // reload the options - print "trying to load options"; self::loadOptions($options); // dump the YAML From 0cee5e684de2520721d8552e6f93814454b964ef Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 6 May 2016 11:01:31 -0400 Subject: [PATCH 261/436] removing the generate step. tough to debug --- src/PatternLab/InstallerUtil.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 15132d9b..5dd7a9d1 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -653,11 +653,7 @@ protected static function runTasks($installerInfo) { if ($installerInfo["projectInstall"]) { Console::writeLine(""); - $g = new Generator(); - $g->generate(array("foo" => "bar")); - - Console::writeLine(""); - Console::writeInfo("type php core/console --server to start the built-in server and see Pattern Lab...", false, true); + Console::writeInfo("Need better intro copy here...", false, true); } From bc59a0ba691b3c083976e71359c57ae467c079b1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 13 May 2016 21:53:24 -0400 Subject: [PATCH 262/436] remove components if installed for a given package that's being deleted --- src/PatternLab/InstallerUtil.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 5dd7a9d1..d49eea57 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -542,7 +542,11 @@ public static function prePackageUninstallCmd($event) { self::scanForPatternEngineRule($pathBase,true); } - // go over .json in patternlab-components/, remove references to packagename + // remove the component package file if it exists + $jsonFile = Config::getOption("componentDir")."/packages/".str_replace("/","-",$name).".json"; + if (file_exists($jsonFile)) { + unlink($jsonFile); + } } From 0e9ad2ff6f3ea5fe4266f4214457ddcd80cf57fd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 13 May 2016 22:36:44 -0400 Subject: [PATCH 263/436] trying to get a good pathBase for removing files --- src/PatternLab/InstallerUtil.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index d49eea57..e1439bab 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -532,7 +532,9 @@ public static function prePackageUninstallCmd($event) { $package = $event->getOperation()->getPackage(); $type = $package->getType(); $name = $package->getName(); - $pathBase = $package->getTargetDir(); + $pathBase = $event->getComposer()->getInstallationManager()->getInstallPath($package); + + print "pathBase: ".$pathBase; // see if the package has a listener and remove it self::scanForListener($pathBase,true); From 7e29f092837e1b8068f64ad66531fb7dc65a3174 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 13 May 2016 22:53:58 -0400 Subject: [PATCH 264/436] getting package details from the project installer --- src/PatternLab/InstallerUtil.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index e1439bab..1881c237 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -521,21 +521,15 @@ public static function postUpdateCmd($installerInfo, $event) { /** * Make sure pattern engines and listeners are removed on uninstall - * @param {Object} a script event object from composer + * @param {String} the name of the package to be removed + * @param {String} the type of the package to be removed + * @param {String} the path of the package to be removed */ - public static function prePackageUninstallCmd($event) { + public static function prePackageUninstallCmd($name, $type, $pathBase) { // run the console and config inits self::init(); - // get package info - $package = $event->getOperation()->getPackage(); - $type = $package->getType(); - $name = $package->getName(); - $pathBase = $event->getComposer()->getInstallationManager()->getInstallPath($package); - - print "pathBase: ".$pathBase; - // see if the package has a listener and remove it self::scanForListener($pathBase,true); From 97a97c503dee1ce1f5f2632497d64df7ac27eb01 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 13 May 2016 23:23:26 -0400 Subject: [PATCH 265/436] post update now splits based on a package being removed vs. added --- src/PatternLab/InstallerUtil.php | 70 ++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 1881c237..68350887 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -504,44 +504,21 @@ protected static function pathExists($packageName,$path) { */ public static function postInstallCmd($installerInfo, $event) { - self::runTasks($installerInfo); + self::packagesInstall($installerInfo); } /** - * Run the PL tasks when Composer runs an update command + * Run the PL tasks when Composer runs an update command. this also runs after a package is removed. * @param {Array} collected package info * @param {Object} a script event object from composer */ public static function postUpdateCmd($installerInfo, $event) { - self::runTasks($installerInfo); - - } - - /** - * Make sure pattern engines and listeners are removed on uninstall - * @param {String} the name of the package to be removed - * @param {String} the type of the package to be removed - * @param {String} the path of the package to be removed - */ - public static function prePackageUninstallCmd($name, $type, $pathBase) { - - // run the console and config inits - self::init(); - - // see if the package has a listener and remove it - self::scanForListener($pathBase,true); - - // see if the package is a pattern engine and remove the rule - if ($type == "patternlab-patternengine") { - self::scanForPatternEngineRule($pathBase,true); - } - - // remove the component package file if it exists - $jsonFile = Config::getOption("componentDir")."/packages/".str_replace("/","-",$name).".json"; - if (file_exists($jsonFile)) { - unlink($jsonFile); + if ($installerInfo["packagesRemove"]) { + self::packagesRemove($installerInfo); + } else { + self::packagesInstall($installerInfo); } } @@ -599,7 +576,7 @@ protected static function removeDots($path) { * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file * @param {Array} the info culled from installing various pattern lab-related packages */ - protected static function runTasks($installerInfo) { + protected static function packagesInstall($installerInfo) { // initialize a bunch of stuff like config and console self::init(); @@ -659,6 +636,39 @@ protected static function runTasks($installerInfo) { } + /** + * Make sure pattern engines and listeners are removed on uninstall + * @param {String} the name of the package to be removed + * @param {String} the type of the package to be removed + * @param {String} the path of the package to be removed + */ + public static function packagesRemove($name, $type, $pathBase) { + + // run the console and config inits + self::init(); + + $packages = $installerInfo["packages"]; + + foreach ($packages as $package) { + + // see if the package has a listener and remove it + self::scanForListener($pathBase,true); + + // see if the package is a pattern engine and remove the rule + if ($type == "patternlab-patternengine") { + self::scanForPatternEngineRule($pathBase,true); + } + + // remove the component package file if it exists + $jsonFile = Config::getOption("componentDir")."/packages/".str_replace("/","-",$name).".json"; + if (file_exists($jsonFile)) { + unlink($jsonFile); + } + + } + + } + /** * Scan the package for a listener * @param {String} the path for the package From 82375c39851e28a512bf5cfedfe205458e05ff2a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 13 May 2016 23:39:47 -0400 Subject: [PATCH 266/436] providing correct number of args for uninstall --- src/PatternLab/InstallerUtil.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 68350887..3c666748 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -573,7 +573,7 @@ protected static function removeDots($path) { } /** - * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file + * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file on install * @param {Array} the info culled from installing various pattern lab-related packages */ protected static function packagesInstall($installerInfo) { @@ -637,12 +637,10 @@ protected static function packagesInstall($installerInfo) { } /** - * Make sure pattern engines and listeners are removed on uninstall - * @param {String} the name of the package to be removed - * @param {String} the type of the package to be removed - * @param {String} the path of the package to be removed + * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file on uninstall + * @param {Array} the info culled from installing various pattern lab-related packages */ - public static function packagesRemove($name, $type, $pathBase) { + public static function packagesRemove($installerInfo) { // run the console and config inits self::init(); From d66b57f9cc8d6c9aba5e13a2e45f6dd3b1d16fdc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 13 May 2016 23:58:50 -0400 Subject: [PATCH 267/436] reworking the uninstall stuff again --- src/PatternLab/InstallerUtil.php | 36 +++++++++++++------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 3c666748..918bfe43 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -515,9 +515,7 @@ public static function postInstallCmd($installerInfo, $event) { */ public static function postUpdateCmd($installerInfo, $event) { - if ($installerInfo["packagesRemove"]) { - self::packagesRemove($installerInfo); - } else { + if (!$installerInfo["packagesRemove"]) { self::packagesInstall($installerInfo); } @@ -638,31 +636,25 @@ protected static function packagesInstall($installerInfo) { /** * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file on uninstall - * @param {Array} the info culled from installing various pattern lab-related packages + * @param {Array} the info culled from a pattern lab-related package that's being removed */ - public static function packagesRemove($installerInfo) { + public static function packageRemove($packageInfo) { // run the console and config inits self::init(); - $packages = $installerInfo["packages"]; + // see if the package has a listener and remove it + self::scanForListener($packageInfo["pathBase"],true); - foreach ($packages as $package) { - - // see if the package has a listener and remove it - self::scanForListener($pathBase,true); - - // see if the package is a pattern engine and remove the rule - if ($type == "patternlab-patternengine") { - self::scanForPatternEngineRule($pathBase,true); - } - - // remove the component package file if it exists - $jsonFile = Config::getOption("componentDir")."/packages/".str_replace("/","-",$name).".json"; - if (file_exists($jsonFile)) { - unlink($jsonFile); - } - + // see if the package is a pattern engine and remove the rule + if ($packageInfo["type"] == "patternlab-patternengine") { + self::scanForPatternEngineRule($packageInfo["pathBase"],true); + } + + // remove the component package file if it exists + $jsonFile = Config::getOption("componentDir")."/packages/".str_replace("/","-",$packageInfo["name"]).".json"; + if (file_exists($jsonFile)) { + unlink($jsonFile); } } From 7655890b4546f7fdd335dd2e4153518c3a77f93c Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Sat, 14 May 2016 10:17:34 +0300 Subject: [PATCH 268/436] Fix 'All' views when using folders below patternSubType --- .../PatternData/Exporters/PatternPartialsExporter.php | 2 +- src/PatternLab/PatternData/Rules/PatternRule.php | 2 +- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 7e4eebd7..090894ab 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -42,7 +42,7 @@ public function run($type = "", $subtype = "") { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] == 2) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { + if (($patternStoreData["category"] == "pattern") && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index bf2450a4..010c65de 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -94,7 +94,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "extraOutput" => array()); // add any subtype info if necessary - if ($depth == 2) { + if ($depth > 1) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; $patternStoreData["breadcrumb"] = $patternTypeClean." > ".$patternSubtypeClean; diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 242df147..4d18b61a 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -112,7 +112,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "pathOrigDash" => $patternPathOrigDash); // add any subtype info if necessary - if ($depth == 2) { + if ($depth > 1) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; $patternStoreData["breadcrumb"] = $patternType." > ".$patternSubtype; From 028a42f5ad068b0d470bd99fdc62c2d76b2a6302 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Sat, 14 May 2016 13:09:36 -0700 Subject: [PATCH 269/436] adding "yml" as a data file extension on top of "yaml" and "json" --- src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php | 2 +- src/PatternLab/PatternData/Rules/PatternInfoRule.php | 2 +- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php index 275f1178..ecba0b56 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php @@ -26,7 +26,7 @@ public function __construct($options) { parent::__construct($options); $this->depthProp = 3; // 3 means that depth won't be checked - $this->extProp = "json||yaml"; + $this->extProp = "json||yaml||yml"; $this->isDirProp = false; $this->isFileProp = true; $this->searchProp = ".listitems."; diff --git a/src/PatternLab/PatternData/Rules/PatternInfoRule.php b/src/PatternLab/PatternData/Rules/PatternInfoRule.php index d2509211..b18818d9 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoRule.php @@ -26,7 +26,7 @@ public function __construct($options) { parent::__construct($options); $this->depthProp = 3; // 3 means that depth won't be checked - $this->extProp = "json||yaml"; + $this->extProp = "json||yaml||yml"; $this->isDirProp = false; $this->isFileProp = true; $this->searchProp = ""; diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 242df147..9fee61aa 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -26,7 +26,7 @@ public function __construct($options) { parent::__construct($options); $this->depthProp = 3; // 3 means that depth won't be checked - $this->extProp = "json||yaml"; + $this->extProp = "json||yaml||yml"; $this->isDirProp = false; $this->isFileProp = true; $this->searchProp = "~"; From e23dbe118ec8931683f82b1ad309b690684036d0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 14 May 2016 21:44:21 -0400 Subject: [PATCH 270/436] fixing name. was removed in a previous commit erroneously. orig mis-typed the var name. --- src/PatternLab/Fetch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 1d5a2ccb..a2971e84 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -203,7 +203,7 @@ protected function mirrorDist($sourceDir, $tempDirDist) { // mirror dist to source Console::writeInfo("installing the starterkit files..."); $fs = new Filesystem(); - $fs->mirror($tempDirDist, $sourceDir, null); + $fs->mirror($tempDirDist, $sourceDir, null, $fsOptions); Console::writeInfo("starterkit files have been installed..."); } From c2f5d90f2a24c1d0b08c695a24ae975211f8f00e Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 16 May 2016 16:30:45 -0700 Subject: [PATCH 271/436] only setting $title variable if present in md description --- src/PatternLab/PatternData/Rules/DocumentationRule.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index 5abbcbfc..d53bcb02 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -81,11 +81,14 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternStoreKey = ($patternSubtypeDoc) ? $docPartial."-plsubtype" : $docPartial; $patternStoreData = array("category" => $category, - "nameClean" => $title, "desc" => $markdown, "descExists" => true, "meta" => $yaml, "full" => $doc); + + if (isset($title)) { + $patternStoreData["nameClean"] = $title; + } // if the pattern data store already exists make sure this data overwrites it $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; From 7f3e77dc1e2019d5b5c6dbf143fadbe85d1e0fdd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 17 May 2016 22:11:35 -0400 Subject: [PATCH 272/436] adding new colors --- src/PatternLab/Console.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index c8da4588..6d7a4ad9 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -56,6 +56,13 @@ public static function init() { $colorTheme["warning"] = "yellow"; $colorTheme["error"] = "red"; $colorTheme["strong"] = "bold"; + $colorTheme["fire1"] = "color[196]"; + $colorTheme["fire2"] = "color[202]"; + $colorTheme["fire3"] = "color[208]"; + $colorTheme["fire4"] = "color[214]"; + $colorTheme["fire5"] = "color[220]"; + $colorTheme["fire6"] = "color[226]"; + $colorTheme["cool"] = "color[19]"; self::$color->setTheme($colorTheme); } From 5008526d0e34b770ecc02856d1f841194f76867b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 17 May 2016 22:11:50 -0400 Subject: [PATCH 273/436] adding a welcome message --- src/PatternLab/InstallerUtil.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 918bfe43..cc917fc0 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -628,8 +628,16 @@ protected static function packagesInstall($installerInfo) { if ($installerInfo["projectInstall"]) { Console::writeLine(""); - Console::writeInfo("Need better intro copy here...", false, true); - + Console::writeLine("

Thank you for installing...

", false, true); + Console::writeLine("( ( "); + Console::writeLine(")\ ) ) ) )\ ) )"); + Console::writeLine("(()/( ) ( /(( /( ( ( (()/( ) ( /("); + Console::writeLine("/(_)| /( )\())\())))\ )( ( /(_))( /( )\())"); + Console::writeLine("(_)) )(_)|_))(_))//((_|()\ )\ )(_)) )(_)|(_)\"); + Console::writeLine("| _ ((_)_| |_| |_(_)) ((_)_(_/(| | ((_)_| |(_)"); + Console::writeLine("| _/ _` | _| _/ -_)| '_| ' \)) |__/ _` | '_ \ "); + Console::writeLine("|_| \__,_|\__|\__\___||_| |_||_||____\__,_|_.__/ ", false, true); + } } From 90461cb75aefe085afdbbfa0aa1ebf05a80a2aab Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 18 May 2016 22:11:52 -0400 Subject: [PATCH 274/436] updating composer options --- composer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/composer.json b/composer.json index 3b02a7cc..691c8eea 100644 --- a/composer.json +++ b/composer.json @@ -27,8 +27,6 @@ "PatternLab": "src/" } }, - "minimum-stability": "dev", - "prefer-stable": true, "require": { "php": ">=5.3.6", "michelf/php-markdown": "~1.5", From e4fbbdd992a97a4691812073087e953c1c5884ee Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 18 May 2016 23:44:01 -0400 Subject: [PATCH 275/436] proper spelling for starterkits --- src/PatternLab/InstallerUtil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index cc917fc0..3b2931fd 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -580,8 +580,8 @@ protected static function packagesInstall($installerInfo) { self::init(); // make sure user is prompted to install starterkit - if (!empty($installerInfo["starterKitSuggestions"])) { - self::promptStarterKitInstall($installerInfo["starterKitSuggestions"]); + if (!empty($installerInfo["suggestedStarterKits"])) { + self::promptStarterKitInstall($installerInfo["suggestedStarterKits"]); } // reorder packages so the starterkit is first if it's being installed as a package From 78d24ff2021a3367b4f6f876966d56b7626c0fbc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 18 May 2016 23:53:32 -0400 Subject: [PATCH 276/436] fixing a spelling mistake --- src/PatternLab/InstallerUtil.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index cc917fc0..3b2931fd 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -580,8 +580,8 @@ protected static function packagesInstall($installerInfo) { self::init(); // make sure user is prompted to install starterkit - if (!empty($installerInfo["starterKitSuggestions"])) { - self::promptStarterKitInstall($installerInfo["starterKitSuggestions"]); + if (!empty($installerInfo["suggestedStarterKits"])) { + self::promptStarterKitInstall($installerInfo["suggestedStarterKits"]); } // reorder packages so the starterkit is first if it's being installed as a package From 991533314f24e074dc6148ddf5ee76e7bc74acc4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 18 May 2016 23:57:02 -0400 Subject: [PATCH 277/436] setting correct var name --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 3b2931fd..c5a32711 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -548,7 +548,7 @@ protected static function promptStarterKitInstall($starterKitSuggestions) { Console::writeLine(""); $f = new Fetch(); - $result = $f->fetchStarterKit($suggestions[$result]); + $result = $f->fetchStarterKit($starterKitSuggestions[$result]); } From 94d7b43c51b1ff2d5a702b1a143f3f60df369775 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 19 May 2016 10:02:07 -0400 Subject: [PATCH 278/436] gracefully handling missing packages --- src/PatternLab/InstallerUtil.php | 58 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index c5a32711..b78aaa2a 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -585,35 +585,39 @@ protected static function packagesInstall($installerInfo) { } // reorder packages so the starterkit is first if it's being installed as a package - $packages = $installerInfo["packages"]; - $packages = array_merge(array_filter($packages, "self::includeStarterKit"), array_filter($packages, "self::excludeStarterKit")); - - foreach ($packages as $package) { - - // set-up package info - $extra = $package["extra"]; - $type = $package["type"]; - $name = $package["name"]; - $pathBase = $package["pathBase"]; - $pathDist = $package["pathDist"]; - - // make sure that it has the name-spaced section of data to be parsed. if it exists parse it - if (!empty($extra)) { - self::parseComposerExtraList($extra, $name, $pathDist); - } + if (isset($installerInfo["packages"])) { - // see if the package has a listener - self::scanForListener($pathBase); + $packages = $installerInfo["packages"]; + $packages = array_merge(array_filter($packages, "self::includeStarterKit"), array_filter($packages, "self::excludeStarterKit")); - // address other specific needs based on type - if ($type == "patternlab-patternengine") { - self::scanForPatternEngineRule($pathBase); - } else if ($type == "patternlab-starterkit") { - Config::updateConfigOption("starterKit",$name); - Config::updateConfigOption("starterKitPath",$pathBase); - } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { - Config::updateConfigOption("styleguideKit",$name); - Config::updateConfigOption("styleguideKitPath",$pathBase); + foreach ($packages as $package) { + + // set-up package info + $extra = $package["extra"]; + $type = $package["type"]; + $name = $package["name"]; + $pathBase = $package["pathBase"]; + $pathDist = $package["pathDist"]; + + // make sure that it has the name-spaced section of data to be parsed. if it exists parse it + if (!empty($extra)) { + self::parseComposerExtraList($extra, $name, $pathDist); + } + + // see if the package has a listener + self::scanForListener($pathBase); + + // address other specific needs based on type + if ($type == "patternlab-patternengine") { + self::scanForPatternEngineRule($pathBase); + } else if ($type == "patternlab-starterkit") { + Config::updateConfigOption("starterKit",$name); + Config::updateConfigOption("starterKitPath",$pathBase); + } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { + Config::updateConfigOption("styleguideKit",$name); + Config::updateConfigOption("styleguideKitPath",$pathBase); + } + } } From c3b021688a6daef2972864b08e5cbe156e3ede13 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 19 May 2016 19:52:16 -0700 Subject: [PATCH 279/436] adding http:// prefix to url so it is clickable --- src/PatternLab/Console/Commands/ServerCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index ac3ef817..bcc41fc3 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -49,7 +49,7 @@ public function run() { $host = $port ? $host.":".$port : $host.":8080"; // start-up the server with the router - Console::writeInfo("server started on ".$host.". use ctrl+c to exit..."); + Console::writeInfo("server started on http://".$host.". use ctrl+c to exit..."); passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S ".$host." ".$coreDir."/server/router.php"); } From b405d284affda2ca97ebdfbada90cb128fa8c32b Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 19 May 2016 19:53:21 -0700 Subject: [PATCH 280/436] adding space --- src/PatternLab/Console/Commands/ServerCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index bcc41fc3..84722915 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -49,7 +49,7 @@ public function run() { $host = $port ? $host.":".$port : $host.":8080"; // start-up the server with the router - Console::writeInfo("server started on http://".$host.". use ctrl+c to exit..."); + Console::writeInfo("server started on http://".$host." - use ctrl+c to exit..."); passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S ".$host." ".$coreDir."/server/router.php"); } From 51ba7b11d1003d4a083f6fe6cc9b585f6a86f0d9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 16:14:37 -0400 Subject: [PATCH 281/436] removing encoded versions of files --- src/PatternLab/Builder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index b4dad348..368ad377 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -243,9 +243,8 @@ protected function generatePatterns($options = array()) { // modify the pattern mark-up $markup = $patternStoreData["code"]; - $markupEncoded = htmlentities($markup,ENT_COMPAT,"UTF-8"); $markupFull = $patternStoreData["header"].$markup.$patternStoreData["footer"]; - $markupEngine = htmlentities(file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension),ENT_COMPAT,"UTF-8"); + $markupEngine = file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension); // if the pattern directory doesn't exist create it if (!is_dir($patternPublicDir."/".$path)) { @@ -255,7 +254,7 @@ protected function generatePatterns($options = array()) { // write out the various pattern files file_put_contents($patternPublicDir."/".$path."/".$path.".html",$markupFull); if (!$exportFiles) { - file_put_contents($patternPublicDir."/".$path."/".$path.".escaped.html",$markupEncoded); + file_put_contents($patternPublicDir."/".$path."/".$path.".markup-only.html",$markup); file_put_contents($patternPublicDir."/".$path."/".$path.".".$patternExtension,$markupEngine); } /* From 283010d061aa238cbe865691f0b1ee261ee5df01 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 20:35:50 -0400 Subject: [PATCH 282/436] correcting for a bad saved full path --- config/config.yml.default | 1 + src/PatternLab/Config.php | 51 +++++++++++++++++++++++++------- src/PatternLab/InstallerUtil.php | 7 ++--- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/config/config.yml.default b/config/config.yml.default index b7094043..add99add 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -37,3 +37,4 @@ cacheBusterOn: "true" exportDir: "export" publicDir: "public" sourceDir: "source" +styleguideKitPath: "" diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 1865a73f..122db4b7 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -74,6 +74,32 @@ public static function getOptions() { return self::$options; } + /** + * Review the given styleguideKitPath to handle pre-2.1.0 backwards compatibility + * @param {String} styleguideKitPath from config.yml + * + * @return {String} the final, post-2.1.0-style styleguideKitPath + */ + protected static function getStyleguideKitPath($styleguideKitPath) { + + $styleguideKitPathFinal = ""; + if ($styleguideKitPath[0] == DIRECTORY_SEPARATOR) { + if (strpos($styleguideKitPath, DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR === 0)) { + $styleguideKitPathFinal = $styleguideKitPath; // mistaken set-up, pass to final for clean-up + } else if (strpos($styleguideKitPath, self::$options["baseDir"]) === 0) { + $styleguideKitPathFinal = str_replace(self::$options["baseDir"], "", $styleguideKitPath); // just need to peel off the base + } else if (strpos($styleguideKitPath, DIRECTORY_SEPARATOR."vendor") !== false) { + $parts = explode(DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR, $styleguideKitPath); // set on another machine's config.yml? try to be smart about it + $styleguideKitPathFinal = "vendor".DIRECTORY_SEPARATOR.$parts[1]; + Console::writeInfo("Please double-check the styleguideKitPath option in ./config/config.yml. It should be a path relative to the root of your Pattern Lab project..."); + } + } + + Console::writeInfo($styleguideKitPathFinal); + return $styleguideKitPathFinal; + + } + /** * Adds the config options to a var to be accessed from the rest of the system * If it's an old config or no config exists this will update and generate it. @@ -172,17 +198,20 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs - self::$options["configDir"] = self::$userConfigDir; - self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; - self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; - self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; - self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts"; - self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source"; - self::$options["componentDir"] = self::$options["publicDir"]."/patternlab-components"; - self::$options["dataDir"] = self::$options["sourceDir"]."/_data"; - self::$options["patternExportDir"] = self::$options["exportDir"]."/patterns"; - self::$options["patternPublicDir"] = self::$options["publicDir"]."/patterns"; - self::$options["patternSourceDir"] = self::$options["sourceDir"]."/_patterns"; + self::$options["configDir"] = self::$userConfigDir; + self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; + self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; + self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; + self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts"; + self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source"; + self::$options["componentDir"] = self::$options["publicDir"]."/patternlab-components"; + self::$options["dataDir"] = self::$options["sourceDir"]."/_data"; + self::$options["patternExportDir"] = self::$options["exportDir"]."/patterns"; + self::$options["patternPublicDir"] = self::$options["publicDir"]."/patterns"; + self::$options["patternSourceDir"] = self::$options["sourceDir"]."/_patterns"; + + // handle a pre-2.1.0 styleguideKitPath before saving it + self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"])); // make sure styleguideExcludes is set to an array even if it's empty if (is_string(self::$options["styleGuideExcludes"])) { diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index b78aaa2a..509f0151 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -610,12 +610,11 @@ protected static function packagesInstall($installerInfo) { // address other specific needs based on type if ($type == "patternlab-patternengine") { self::scanForPatternEngineRule($pathBase); - } else if ($type == "patternlab-starterkit") { - Config::updateConfigOption("starterKit",$name); - Config::updateConfigOption("starterKitPath",$pathBase); } else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) { + $dir = str_replace(Config::getOption("baseDir"), "", $pathBase); + $dir = ($dir[strlen($dir)-1] == DIRECTORY_SEPARATOR) ? rtrim($dir, DIRECTORY_SEPARATOR) : $dir; Config::updateConfigOption("styleguideKit",$name); - Config::updateConfigOption("styleguideKitPath",$pathBase); + Config::updateConfigOption("styleguideKitPath",$dir); } } From 67728753a086ed7f99d7691aa69608413f67de64 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 20:38:49 -0400 Subject: [PATCH 283/436] adding Console::log() as an alias of Console::writeInfo() --- src/PatternLab/Console.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 6d7a4ad9..68b24844 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -477,6 +477,16 @@ public static function writeInfo($line,$doubleSpace = false,$doubleBreak = false self::writeLine($lineFinal,$doubleSpace,$doubleBreak); } + /** + * Alias for writeInfo because I keep wanting to use it + * @param {String} the content to be written out + * @param {Boolean} if there should be two spaces added to the beginning of the line + * @param {Boolean} if there should be two breaks added to the end of the line + */ + public static function log($line,$doubleSpace = false,$doubleBreak = false) { + self::writeInfo($line,$doubleSpace = false,$doubleBreak = false); + } + /** * Write out a line to the console * @param {String} the content to be written out From 4eba993554af6b5efdfa12a05b435edb386480aa Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 20:43:29 -0400 Subject: [PATCH 284/436] removing a debug message --- src/PatternLab/Config.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 122db4b7..2754e823 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -95,7 +95,6 @@ protected static function getStyleguideKitPath($styleguideKitPath) { } } - Console::writeInfo($styleguideKitPathFinal); return $styleguideKitPathFinal; } From 81a1bc2a733ee6b1d39ef8eb7aed6ec40da49312 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 21:21:18 -0400 Subject: [PATCH 285/436] double-checking some important directories exist before running PL --- src/PatternLab/Config.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 2754e823..bd5f4554 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -93,6 +93,8 @@ protected static function getStyleguideKitPath($styleguideKitPath) { $styleguideKitPathFinal = "vendor".DIRECTORY_SEPARATOR.$parts[1]; Console::writeInfo("Please double-check the styleguideKitPath option in ./config/config.yml. It should be a path relative to the root of your Pattern Lab project..."); } + } else { + $styleguideKitPathFinal = $styleguideKitPath; // fingers crossed everything is fine } return $styleguideKitPathFinal; @@ -212,6 +214,18 @@ public static function init($baseDir = "", $verbose = true) { // handle a pre-2.1.0 styleguideKitPath before saving it self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"])); + // double-check a few directories are real + if (!is_dir(self::$options["sourceDir"])) { + Console::writeError("hrm... i can't seem to find the directory with your source files. are you sure they're at ".Console::getHumanReadablePath(self::$options["sourceDir"])."? you can fix this in ./config/config.yml by editing sourceDir. sorry, stopping pattern lab... :("); + } + if (!is_dir(self::$options["publicDir"])) { + Console::writeError("hrm... i can't seem to find the directory where you want to write your styleguide. are you sure it's at ".Console::getHumanReadablePath(self::$options["sourceDir"])."? you can fix this in ./config/config.yml by editing publicDir. sorry, stopping pattern lab... :("); + } + if (!is_dir(self::$options["styleguideKitPath"])) { + Console::writeError("hrm... i can't seem to find the directory where your styleguide files are located. are you sure it's at ".Console::getHumanReadablePath(self::$options["styleguideKitPath"])."? you can fix this in ./config/config.yml by editing styleguideKitPath. sorry, stopping pattern lab... :("); + } + + // make sure styleguideExcludes is set to an array even if it's empty if (is_string(self::$options["styleGuideExcludes"])) { self::$options["styleGuideExcludes"] = array(); From 480205f541a4891c830689b9e08b08e064850a6a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 21:21:40 -0400 Subject: [PATCH 286/436] smarter handling of styleguidekit files being missing --- src/PatternLab/Template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index d17d03c6..ff497797 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -48,8 +48,10 @@ public static function init() { // load pattern-lab's resources $partialPath = $styleguideKitPath."/views/partials"; - self::$htmlHead = file_get_contents($partialPath."/general-header.".$patternExtension); - self::$htmlFoot = file_get_contents($partialPath."/general-footer.".$patternExtension); + $generalHeaderPath = $partialPath."/general-header.".$patternExtension; + $generalFooterPath = $partialPath."/general-footer.".$patternExtension; + self::$htmlHead = (file_exists($generalHeaderPath)) ? file_get_contents($generalHeaderPath) : ""; + self::$htmlFoot = (file_exists($generalFooterPath)) ? file_get_contents($generalFooterPath) : ""; // gather the user-defined header and footer information $patternHeadPath = $sourceDir."/_meta/_00-head.".$patternExtension; From abb53ffdd6abd7130925d7e3d4bfc51de7392bb0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 21:44:19 -0400 Subject: [PATCH 287/436] tracking down a bug with the offset in a var --- src/PatternLab/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index bd5f4554..389188b1 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -80,10 +80,10 @@ public static function getOptions() { * * @return {String} the final, post-2.1.0-style styleguideKitPath */ - protected static function getStyleguideKitPath($styleguideKitPath) { + protected static function getStyleguideKitPath($styleguideKitPath = "") { $styleguideKitPathFinal = ""; - if ($styleguideKitPath[0] == DIRECTORY_SEPARATOR) { + if (isset($styleguideKitPath[0]) && ($styleguideKitPath[0] == DIRECTORY_SEPARATOR)) { if (strpos($styleguideKitPath, DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR === 0)) { $styleguideKitPathFinal = $styleguideKitPath; // mistaken set-up, pass to final for clean-up } else if (strpos($styleguideKitPath, self::$options["baseDir"]) === 0) { From e3bc7072f413af4859f88ac07456220661de3fa7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 21:49:08 -0400 Subject: [PATCH 288/436] tracking down a bug with the offset in a var --- src/PatternLab/Config.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 389188b1..32e3bb66 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -37,9 +37,11 @@ class Config { */ protected static function cleanDir($dir) { - $dir = trim($dir); - $dir = ($dir[0] == DIRECTORY_SEPARATOR) ? ltrim($dir, DIRECTORY_SEPARATOR) : $dir; - $dir = ($dir[strlen($dir)-1] == DIRECTORY_SEPARATOR) ? rtrim($dir, DIRECTORY_SEPARATOR) : $dir; + if (isset($dir[0])) { + $dir = trim($dir); + $dir = ($dir[0] == DIRECTORY_SEPARATOR) ? ltrim($dir, DIRECTORY_SEPARATOR) : $dir; + $dir = ($dir[strlen($dir)-1] == DIRECTORY_SEPARATOR) ? rtrim($dir, DIRECTORY_SEPARATOR) : $dir; + } return $dir; From a5a6bb2beb95ba66f6969937c58591f020980b48 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 21:53:43 -0400 Subject: [PATCH 289/436] removing styleguideKitPath from the default list --- config/config.yml.default | 1 - src/PatternLab/Config.php | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/config.yml.default b/config/config.yml.default index add99add..b7094043 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -37,4 +37,3 @@ cacheBusterOn: "true" exportDir: "export" publicDir: "public" sourceDir: "source" -styleguideKitPath: "" diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 32e3bb66..745b2e39 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -214,7 +214,9 @@ public static function init($baseDir = "", $verbose = true) { self::$options["patternSourceDir"] = self::$options["sourceDir"]."/_patterns"; // handle a pre-2.1.0 styleguideKitPath before saving it - self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"])); + if (isset(self::$options["styleguideKitPath"])) { + self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"])); + } // double-check a few directories are real if (!is_dir(self::$options["sourceDir"])) { From 2b8a58166bb4e0f700f2b5de690c45eb02d482c8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 20 May 2016 22:11:24 -0400 Subject: [PATCH 290/436] smarter handling of missing dirs and dir options --- src/PatternLab/Config.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 745b2e39..3c3ebe4c 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -219,13 +219,18 @@ public static function init($baseDir = "", $verbose = true) { } // double-check a few directories are real - if (!is_dir(self::$options["sourceDir"])) { + // refactor this at some point. it's verbose + if (!isset(self::$options["sourceDir"])) { + Console::writeError("please make sure sourceDir is set in ./config/config.yml by adding 'sourceDir=some/path'. sorry, stopping pattern lab... :("); + } else if (!is_dir(self::$options["sourceDir"])) { Console::writeError("hrm... i can't seem to find the directory with your source files. are you sure they're at ".Console::getHumanReadablePath(self::$options["sourceDir"])."? you can fix this in ./config/config.yml by editing sourceDir. sorry, stopping pattern lab... :("); } - if (!is_dir(self::$options["publicDir"])) { + if (!isset(self::$options["publicDir"])) { + Console::writeError("please make sure publicDir is set in ./config/config.yml by adding 'publicDir=some/path'. sorry, stopping pattern lab... :("); + } else if (!is_dir(self::$options["publicDir"])) { Console::writeError("hrm... i can't seem to find the directory where you want to write your styleguide. are you sure it's at ".Console::getHumanReadablePath(self::$options["sourceDir"])."? you can fix this in ./config/config.yml by editing publicDir. sorry, stopping pattern lab... :("); } - if (!is_dir(self::$options["styleguideKitPath"])) { + if (isset(self::$options["styleguideKitPath"]) && !is_dir(self::$options["styleguideKitPath"])) { Console::writeError("hrm... i can't seem to find the directory where your styleguide files are located. are you sure it's at ".Console::getHumanReadablePath(self::$options["styleguideKitPath"])."? you can fix this in ./config/config.yml by editing styleguideKitPath. sorry, stopping pattern lab... :("); } From 8678f58e8e8298013ef2f547a69197d1b554c58a Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 22 May 2016 20:37:04 -0400 Subject: [PATCH 291/436] updating --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44657470..eb6ef7e4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Pattern Lab Core -This repository contains the core functionality for Pattern Lab. Pattern Lab Core is designed to be included as a dependency within Editions. \ No newline at end of file +This repository contains the core functionality for Pattern Lab. Pattern Lab Core is designed to be included as a dependency within Editions. Turn it up. From e1dce363dc5f3857ae89a9c5bc2d3d5d00058b71 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 May 2016 14:55:55 -0400 Subject: [PATCH 292/436] looser check of source & public dir. will now build --- src/PatternLab/Config.php | 19 +++---------------- src/PatternLab/FileUtil.php | 36 ++++++++++++++++++++++++++++++++++-- src/PatternLab/Template.php | 4 ++++ 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 3c3ebe4c..4ca3ad66 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -218,22 +218,9 @@ public static function init($baseDir = "", $verbose = true) { self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"])); } - // double-check a few directories are real - // refactor this at some point. it's verbose - if (!isset(self::$options["sourceDir"])) { - Console::writeError("please make sure sourceDir is set in ./config/config.yml by adding 'sourceDir=some/path'. sorry, stopping pattern lab... :("); - } else if (!is_dir(self::$options["sourceDir"])) { - Console::writeError("hrm... i can't seem to find the directory with your source files. are you sure they're at ".Console::getHumanReadablePath(self::$options["sourceDir"])."? you can fix this in ./config/config.yml by editing sourceDir. sorry, stopping pattern lab... :("); - } - if (!isset(self::$options["publicDir"])) { - Console::writeError("please make sure publicDir is set in ./config/config.yml by adding 'publicDir=some/path'. sorry, stopping pattern lab... :("); - } else if (!is_dir(self::$options["publicDir"])) { - Console::writeError("hrm... i can't seem to find the directory where you want to write your styleguide. are you sure it's at ".Console::getHumanReadablePath(self::$options["sourceDir"])."? you can fix this in ./config/config.yml by editing publicDir. sorry, stopping pattern lab... :("); - } - if (isset(self::$options["styleguideKitPath"]) && !is_dir(self::$options["styleguideKitPath"])) { - Console::writeError("hrm... i can't seem to find the directory where your styleguide files are located. are you sure it's at ".Console::getHumanReadablePath(self::$options["styleguideKitPath"])."? you can fix this in ./config/config.yml by editing styleguideKitPath. sorry, stopping pattern lab... :("); - } - + // double-check a few directories are real and set-up + FileUtil::checkPathFromConfig(self::$options["sourceDir"], self::$userConfigPath, "sourceDir"); + FileUtil::checkPathFromConfig(self::$options["publicDir"], self::$userConfigPath, "publicDir"); // make sure styleguideExcludes is set to an array even if it's empty if (is_string(self::$options["styleGuideExcludes"])) { diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index a2a8a67b..1479e298 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -20,10 +20,42 @@ use \Symfony\Component\Filesystem\Exception\IOExceptionInterface; class FileUtil { - + + /** + * Check that a dir from the config exists and try to build it if needed + * @param {String} directory to be checked/built + * @param {String} the config path + * @param {String} the config option that would help them + */ + public static function checkPathFromConfig($path, $configPath, $configOption = "") { + + if (!isset($path)) { + Console::writeError("please make sure ".$configOption." is set in ".Console::getHumanReadablePath($configPath)." by adding '".$configOption."=some/path'. sorry, stopping pattern lab... :("); + } else if (!is_dir($path)) { + Console::writeWarning("i can't seem to find the directory ".Console::getHumanReadablePath($path)."..."); + self::makeDir($path); + Console::writeWarning("i created ".Console::getHumanReadablePath($path)." just in case. you can edit this in ".Console::getHumanReadablePath($configPath)." by editing ".$configOption."..."); + } + + } + + /** + * Make a directory + * @param {String} directory to be made + */ + public static function makeDir($dir) { + $fs = new Filesystem(); + try { + $fs->mkdir($dir); + } catch (IOExceptionInterface $e) { + Console::writeError("an error occurred while creating your directory at ".$e->getPath()."..."); + } + unset($fs); + } + /** * Copies a file from the given source path to the given public path. - * THIS IS NOT FOR PATTERNS + * THIS IS NOT FOR PATTERNS * @param {String} the source file * @param {String} the public file */ diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index ff497797..714f9389 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -46,6 +46,10 @@ public static function init() { $styleguideKit = Config::getOption("styleguideKit"); $styleguideKitPath = Config::getOption("styleguideKitPath"); + if (!$styleguideKitPath || !is_dir($styleguideKitPath)) { + Console::writeError("your styleguide won't render because i can't find your styleguide files. are you sure they're at ".Console::getHumanReadablePath($styleguideKitPath)."? you can fix this in ./config/config.yml by editing styleguideKitPath..."); + } + // load pattern-lab's resources $partialPath = $styleguideKitPath."/views/partials"; $generalHeaderPath = $partialPath."/general-header.".$patternExtension; From 00e3c4af5ba83911bb0c616fb6b0021cdf51514b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 May 2016 14:56:17 -0400 Subject: [PATCH 293/436] if public dir is missing PL will build it --- src/PatternLab/InstallerUtil.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 509f0151..9cb874bc 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -14,6 +14,7 @@ use \PatternLab\Config; use \PatternLab\Console; +use \PatternLab\FileUtil; use \PatternLab\Timer; use \Symfony\Component\Filesystem\Filesystem; use \Symfony\Component\Filesystem\Exception\IOExceptionInterface; @@ -62,7 +63,13 @@ protected static function init() { // make sure the source dir is set-up $sourceDir = Config::getOption("sourceDir"); if (!is_dir($sourceDir)) { - mkdir($sourceDir); + FileUtil::makeDir($sourceDir); + } + + // make sure the public dir is set-up + $publicDir = Config::getOption("publicDir"); + if (!is_dir($publicDir)) { + FileUtil::makeDir($publicDir); } Dispatcher::init(); From f9e0b1e63a9f66ce57ac885826a7505f2a658655 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 May 2016 14:57:03 -0400 Subject: [PATCH 294/436] better handling of missing directory --- src/PatternLab/Builder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index b4dad348..1ea123fe 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -16,6 +16,7 @@ use \PatternLab\Config; use \PatternLab\Data; use \PatternLab\Dispatcher; +use \PatternLab\FileUtil; use \PatternLab\Parsers\Documentation; use \PatternLab\PatternData\Exporters\NavItemsExporter; use \PatternLab\PatternData\Exporters\PatternPartialsExporter; @@ -121,7 +122,7 @@ protected function generateIndex() { // double-check that the data directory exists if (!is_dir($dataDir)) { - mkdir($dataDir); + FileUtil::makeDir($dataDir); } $output = ""; From 9f185a308ef9de77bc26f261b5036ef63c2e3360 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 24 May 2016 15:24:14 -0400 Subject: [PATCH 295/436] fixes #42 --- src/PatternLab/Builder.php | 2 +- .../Exporters/DataLinkExporter.php | 28 ++++++++++--------- .../Exporters/NavItemsExporter.php | 6 ++-- .../Exporters/PatternPartialsExporter.php | 2 +- .../Exporters/PatternPathDestsExporter.php | 2 +- .../Exporters/PatternPathSrcExporter.php | 2 +- .../PatternData/Helpers/LineageHelper.php | 4 +-- .../PatternData/Helpers/PatternCodeHelper.php | 2 +- .../Helpers/PatternStateHelper.php | 2 +- .../PatternData/Helpers/RawPatternHelper.php | 2 +- 10 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 1ea123fe..a04347bf 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -237,7 +237,7 @@ protected function generatePatterns($options = array()) { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && (!$patternStoreData["hidden"])) { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"])) { $path = $patternStoreData["pathDash"]; $pathName = (isset($patternStoreData["pseudo"])) ? $patternStoreData["pathOrig"] : $patternStoreData["pathName"]; diff --git a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php index 3d213b73..9ff86a6c 100644 --- a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php +++ b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php @@ -17,27 +17,29 @@ use \PatternLab\Timer; class DataLinkExporter extends \PatternLab\PatternData\Exporter { - + public function __construct($options = array()) { - + parent::__construct($options); - + } - + public function run() { - + $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - + if ($patternStoreData["category"] == "pattern") { - - $value = "../../patterns/".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; - Data::setOptionLink($patternStoreKey, $value); - + + if (isset($patternStoreData["pathDash"])) { + $value = "../../patterns/".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; + Data::setOptionLink($patternStoreKey, $value); + } + } - + } - + } - + } diff --git a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php index 4b744bd0..e09c2eb2 100644 --- a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php +++ b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php @@ -74,7 +74,7 @@ public function run() { } else if ($patternStoreData["category"] == "pattern") { - if (!$patternStoreData["hidden"]) { + if (isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { // set-up the info for the nav $patternInfo = array("patternPath" => $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html", @@ -124,7 +124,7 @@ public function run() { // add a view all link $navItems["patternTypes"][$patternTypeKey]["patternTypeItems"][$patternSubtypeKey]["patternSubtypeItems"][$subItemsCount] = array( - "patternPath" => $patternType."-".$patternSubtype."/index.html", + "patternPath" => $patternType."-".$patternSubtype."/index.html", "patternName" => "View All", "patternType" => $patternType, "patternSubtype" => $patternSubtype, @@ -144,7 +144,7 @@ public function run() { // add an overall view all link to the menus with sub-menus if (!empty($navItems["patternTypes"][$patternTypeKey]["patternTypeItems"])) { - $navItems["patternTypes"][$patternTypeKey]["patternItems"][] = array("patternPath" => $patternType."/index.html", + $navItems["patternTypes"][$patternTypeKey]["patternItems"][] = array("patternPath" => $patternType."/index.html", "patternName" => "View All", "patternType" => $patternType, "patternSubtype" => "all", diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 090894ab..650b2cfa 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -42,7 +42,7 @@ public function run($type = "", $subtype = "") { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { diff --git a/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php index e6f13d0c..bacf386d 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php @@ -31,7 +31,7 @@ public function run() { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { $nameDash = $patternStoreData["nameDash"]; $typeDash = $patternStoreData["typeDash"]; diff --git a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php index ce29545c..58fd5619 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php @@ -32,7 +32,7 @@ public function run() { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if ($patternStoreData["category"] == "pattern") { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["nameDash"])) { $nameDash = $patternStoreData["nameDash"]; $typeDash = $patternStoreData["typeDash"]; diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index daf1b577..97363a0c 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -95,7 +95,7 @@ public function run() { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && (!isset($patternStoreData["pseudo"]))) { + if (($patternStoreData["category"] == "pattern") && (!isset($patternStoreData["pseudo"])) && isset($patternStoreData["partial"])) { $patternLineagesR = array(); @@ -123,7 +123,7 @@ public function run() { if (PatternData::getOption($haystackKey)) { $path = PatternData::getPatternOption($haystackKey,"pathDash"); - $patternLineagesR[] = array("lineagePattern" => $haystackKey, + $patternLineagesR[] = array("lineagePattern" => $haystackKey, "lineagePath" => "../../patterns/".$path."/".$path.".html"); } diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 5b5c2cd1..7cd4806a 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -57,7 +57,7 @@ public function run() { // iterate to process each pattern foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { $data = Data::getPatternSpecificData($patternStoreKey); diff --git a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php index 8316a1b2..914d649b 100644 --- a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php @@ -35,7 +35,7 @@ public function run() { $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - if ($patternStoreData["category"] == "pattern") { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["state"])) { $patternState = $patternStoreData["state"]; diff --git a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php index 55869f9f..cc201dc2 100644 --- a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php +++ b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php @@ -41,7 +41,7 @@ public function run() { // iterate to get raw data loaded into the PatternData Store foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && !$patternStoreData["hidden"]) { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { // figure out the source path for the pattern to render $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; From 510be37cdf11c218abd9b5ae806009d7002c9086 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 10:12:08 -0400 Subject: [PATCH 296/436] throwing an error if public/index.html is missing --- src/PatternLab/Builder.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index a04347bf..ebcb076f 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -111,6 +111,12 @@ protected function generateAnnotations() { */ protected function generateIndex() { + // bomb if missing index.html + if (!file_exists(Config::getOption("publicDir")."/index.html")) { + $index = Console::getHumanReadablePath(Config::getOption("publicDir")).DIRECTORY_SEPARATOR."index.html"; + Console::writeError("".$index." is missing. grab a copy from your StyleguideKit..."); + } + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); From bcfea21574f34fa25ef6347f0a294b6db71630d8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 11:23:27 -0400 Subject: [PATCH 297/436] adding support for --quiet --- src/PatternLab/Console/Commands/ServerCommand.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index 84722915..62f3b945 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -26,8 +26,9 @@ public function __construct() { Console::setCommand($this->command,"Start the PHP-based server","The server command will start PHP's web server for you.","s"); Console::setCommandOption($this->command,"host:","Provide a custom hostname. Default value is localhost.","To use a custom hostname and the default port:","",""); Console::setCommandOption($this->command,"port:","Provide a custom port. Default value is 8080.","To use a custom port and the default hostname:","",""); + Console::setCommandOption($this->command,"quiet","Turn on quiet mode for the server.","To turn on quiet mode:"); Console::setCommandSample($this->command,"To provide both a custom hostname and port:","--host --port "); - + } public function run() { @@ -48,9 +49,13 @@ public function run() { $port = Console::findCommandOptionValue("port"); $host = $port ? $host.":".$port : $host.":8080"; + $null = Console::findCommandOption("quiet"); + $null = $null ? " >& /dev/null" : ""; + // start-up the server with the router Console::writeInfo("server started on http://".$host." - use ctrl+c to exit..."); - passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S ".$host." ".$coreDir."/server/router.php"); + + passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S ".$host." ".$coreDir."/server/router.php".$null); } From 65c4105fd779c76442fbb2ed40847e7befaf89df Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 11:24:57 -0400 Subject: [PATCH 298/436] fixing output of console help --- src/PatternLab/Console.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 68b24844..1f2875e8 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -367,7 +367,8 @@ public static function writeHelpCommand($command = "") { $lengthLong = 0; foreach ($commandOptions as $option => $attributes) { $optionShort = (!empty($attributes["optionShort"][0]) && (($attributes["optionShort"][0] != "z") || ($attributes["optionShort"] != ""))) ? "|-".$attributes["optionShort"] : ""; - $optionList .= "[--".$attributes["optionLong"].$optionShort."] "; + $optionExtra = (!empty($attributes["optionExtra"])) ? " ".$attributes["optionExtra"] : ""; + $optionList .= "[--".$attributes["optionLong"].$optionShort.$optionExtra."] "; $lengthLong = ($attributes["optionLongLength"] > $lengthLong) ? $attributes["optionLongLength"] : $lengthLong; } @@ -382,7 +383,7 @@ public static function writeHelpCommand($command = "") { self::writeLine(""); self::writeLine("

".$commandLongUC." Command Options

",true,true); self::writeLine("

Usage

:",true,true); - self::writeLine(" php ".self::$self." --".$commandLong.$commandShortInc." ".$commandExampleList.$optionList,true,true); + self::writeLine(" php ".self::$self." --".$commandLong.$commandShortInc." ".$optionList,true,true); // write out the available options if (count($commandOptions) > 0) { From 22ac80da1d4ab1ca429c739ac876a7e75b020bc8 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 13:06:03 -0400 Subject: [PATCH 299/436] adding 'configPath' as an option --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 4ca3ad66..c45cf972 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -202,6 +202,7 @@ public static function init($baseDir = "", $verbose = true) { // set-up the various dirs self::$options["configDir"] = self::$userConfigDir; + self::$options["configPath"] = self::$userConfigPath; self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; From 9e3affb80dc49290ae4c852b9c7520e624fa6489 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 13:06:48 -0400 Subject: [PATCH 300/436] doing a check for default PHP server var. if it doesn't exist check for phpBin option --- src/PatternLab/Console/Commands/ServerCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index 62f3b945..b39a2559 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -52,10 +52,17 @@ public function run() { $null = Console::findCommandOption("quiet"); $null = $null ? " >& /dev/null" : ""; + $php = isset($_SERVER["_"]) ? $_SERVER["_"] : Config::getOption("phpBin"); + + if (!$php) { + $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); + Console::writeError("please add the option `phpBin` with the path to PHP to ".$configPath." before running the server..."); + } + // start-up the server with the router Console::writeInfo("server started on http://".$host." - use ctrl+c to exit..."); - passthru("cd ".$publicDir." && ".$_SERVER["_"]." -S ".$host." ".$coreDir."/server/router.php".$null); + passthru("cd ".$publicDir." && ".$php." -S ".$host." ".$coreDir."/server/router.php".$null); } From f57d3dece7171cac3bb2ce30cd7cb2dce6ddb6d6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 13:45:51 -0400 Subject: [PATCH 301/436] adding support for composer's 'no interaction' mode --- src/PatternLab/Config.php | 13 ++++++++++--- src/PatternLab/Console.php | 20 ++++++++++++++------ src/PatternLab/Fetch.php | 6 +++--- src/PatternLab/InstallerUtil.php | 4 ++-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index c45cf972..237a32a9 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -329,9 +329,16 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal if (is_string($optionValue) && strpos($optionValue,"") !== false) { // prompt for input using the supplied query - $prompt = str_replace("","",str_replace("","",$optionValue)); $options = ""; - $input = Console::promptInput($prompt,$options,false); + $default = ""; + $prompt = str_replace("","",str_replace("","",$optionValue)); + if (strpos($prompt, "") !== false) { + $default = explode("",$prompt); + $default = explode("",$default[1])); + $default = $default[0]; + } + + $input = Console::promptInput($prompt,$options,$default,false); self::writeUpdateConfigOption($optionName,$input); Console::writeTag("ok","config option ".$optionName." updated...", false, true); @@ -352,7 +359,7 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal // prompt for input $prompt = "update the config option ".$optionName." (".$currentOptionValue.") with the value ".$newOptionValue."?"; $options = "Y/n"; - $input = Console::promptInput($prompt,$options); + $input = Console::promptInput($prompt,$options,"Y"); if ($input == "y") { self::writeUpdateConfigOption($optionName,$optionValue); diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 1f2875e8..1ef84e14 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -532,12 +532,13 @@ public static function writeWarning($line,$doubleSpace = false,$doubleBreak = fa * Prompt the user for some input * @param {String} the text for the prompt * @param {String} the text for the options + * @param {String} the text for the default option * @param {Boolean} if we should lowercase the input before sending it back * @param {String} the tag that should be used when drawing the content * * @return {String} trimmed input given by the user */ - public static function promptInput($prompt = "", $options = "", $lowercase = true, $tag = "info") { + public static function promptInput($prompt = "", $options = "", $default = "", $lowercase = true, $tag = "info") { // check prompt if (empty($prompt)) { @@ -552,11 +553,18 @@ public static function promptInput($prompt = "", $options = "", $lowercase = tru // make sure no end-of-line is added $prompt .= " "; - // open the terminal and wait for feedback - $stdin = fopen("php://stdin", "r"); - Console::writeTag($tag,$prompt); - $input = trim(fgets($stdin)); - fclose($stdin); + // make sure we're not running in no interaction mode. if so just use the default for the input + if ((isset($_ENV['COMPOSER_NO_INTERACTION']) && $_ENV['COMPOSER_NO_INTERACTION'])) { + $input = $default; + } else { + + // open the terminal and wait for feedback + $stdin = fopen("php://stdin", "r"); + Console::writeTag($tag,$prompt); + $input = trim(fgets($stdin)); + fclose($stdin); + + } // check to see if it should be lowercased before sending back return ($lowercase) ? strtolower($input) : $input; diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index a2971e84..afeb633e 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -91,8 +91,8 @@ public function fetchStarterKit($starterkit = "") { Console::writeInfo("finished downloading the starterkit..."); // make sure the temp dir exists before copying into it - if (!is_dir($tempDirSK)) { - mkdir($tempDirSK); + if (!is_dir($tempDirSK)) { + mkdir($tempDirSK); } // extract, if the zip is supposed to be unpacked do that (e.g. stripdir) @@ -195,7 +195,7 @@ protected function mirrorDist($sourceDir, $tempDirDist) { $prompt = "a starterkit is already installed. merge the new files with it or replace it?"; $options = "M/r"; - $input = Console::promptInput($prompt,$options); + $input = Console::promptInput($prompt,$options,"M"); $fsOptions = ($input == "r") ? array("delete" => true, "override" => true) : array("delete" => false, "override" => false); } diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 9cb874bc..cbebb5e7 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -484,7 +484,7 @@ protected static function pathExists($packageName,$path) { // prompt for input using the supplied query $prompt = "the path ".$humanReadablePath." already exists. merge or replace with the contents of ".$packageName." package?"; $options = "M/r"; - $input = Console::promptInput($prompt,$options); + $input = Console::promptInput($prompt,$options,"M"); if ($input == "m") { Console::writeTag("ok","contents of ".$humanReadablePath." have been merged with the package's content...", false, true); @@ -548,7 +548,7 @@ protected static function promptStarterKitInstall($starterKitSuggestions) { $prompt = "choose an option or hit return to skip:"; $options = "(ex. 1)"; - $input = Console::promptInput($prompt,$options); + $input = Console::promptInput($prompt,$options,"1"); $result = (int)$input - 1; if (isset($starterKitSuggestions[$result])) { From baabf877112f13bc61b585631f6d8fe9c8d76236 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 16:07:03 -0400 Subject: [PATCH 302/436] fixing syntax issue --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 237a32a9..c7b55203 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -334,7 +334,7 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal $prompt = str_replace("","",str_replace("","",$optionValue)); if (strpos($prompt, "") !== false) { $default = explode("",$prompt); - $default = explode("",$default[1])); + $default = explode("",$default[1]); $default = $default[0]; } From 3c6a29d68394a44228dd4f68fb6865ca00d023c4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 25 May 2016 16:24:50 -0400 Subject: [PATCH 303/436] seeing if i can dump env --- src/PatternLab/Console.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 1ef84e14..79714aca 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -554,6 +554,7 @@ public static function promptInput($prompt = "", $options = "", $default = "", $ $prompt .= " "; // make sure we're not running in no interaction mode. if so just use the default for the input + print_r($_ENV); if ((isset($_ENV['COMPOSER_NO_INTERACTION']) && $_ENV['COMPOSER_NO_INTERACTION'])) { $input = $default; } else { From 319e6e9eb465b4e6eb9a58936a8e914f81309efa Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 26 May 2016 10:04:03 -0400 Subject: [PATCH 304/436] removing a debug statement --- src/PatternLab/Console.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 79714aca..1ef84e14 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -554,7 +554,6 @@ public static function promptInput($prompt = "", $options = "", $default = "", $ $prompt .= " "; // make sure we're not running in no interaction mode. if so just use the default for the input - print_r($_ENV); if ((isset($_ENV['COMPOSER_NO_INTERACTION']) && $_ENV['COMPOSER_NO_INTERACTION'])) { $input = $default; } else { From 6bbfd8460e8ddc94c5eb5cc57744405f4e79e615 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 26 May 2016 10:04:36 -0400 Subject: [PATCH 305/436] adding event and trying to read the arguments --- src/PatternLab/InstallerUtil.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index cbebb5e7..ede01cb6 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -511,7 +511,7 @@ protected static function pathExists($packageName,$path) { */ public static function postInstallCmd($installerInfo, $event) { - self::packagesInstall($installerInfo); + self::packagesInstall($installerInfo, $event); } @@ -523,7 +523,7 @@ public static function postInstallCmd($installerInfo, $event) { public static function postUpdateCmd($installerInfo, $event) { if (!$installerInfo["packagesRemove"]) { - self::packagesInstall($installerInfo); + self::packagesInstall($installerInfo, $event); } } @@ -581,7 +581,9 @@ protected static function removeDots($path) { * Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file on install * @param {Array} the info culled from installing various pattern lab-related packages */ - protected static function packagesInstall($installerInfo) { + protected static function packagesInstall($installerInfo, $event) { + + print_r($event->getArguments()); // initialize a bunch of stuff like config and console self::init(); From be5cf0d384375815bf0b2556e50820881ad3ad1b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 26 May 2016 10:07:39 -0400 Subject: [PATCH 306/436] adding event and trying to read the arguments --- src/PatternLab/InstallerUtil.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index ede01cb6..c2b1dee5 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -583,6 +583,7 @@ protected static function removeDots($path) { */ protected static function packagesInstall($installerInfo, $event) { + Console::log("print args:"); print_r($event->getArguments()); // initialize a bunch of stuff like config and console From d171f9e964d35ba875cb89e921c0e2092735d8a3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 26 May 2016 10:14:20 -0400 Subject: [PATCH 307/436] adding event and trying to read the arguments --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index c2b1dee5..aef2f2d4 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -583,7 +583,7 @@ protected static function removeDots($path) { */ protected static function packagesInstall($installerInfo, $event) { - Console::log("print args:"); + print "arguments:"; print_r($event->getArguments()); // initialize a bunch of stuff like config and console From 94aac0c49e9fed16470a6ae0365f2e0ece6281dc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 26 May 2016 10:37:19 -0400 Subject: [PATCH 308/436] adding event and trying to read the arguments --- src/PatternLab/Console.php | 8 +++++--- src/PatternLab/InstallerUtil.php | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 1ef84e14..d5b4df0f 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -554,9 +554,7 @@ public static function promptInput($prompt = "", $options = "", $default = "", $ $prompt .= " "; // make sure we're not running in no interaction mode. if so just use the default for the input - if ((isset($_ENV['COMPOSER_NO_INTERACTION']) && $_ENV['COMPOSER_NO_INTERACTION'])) { - $input = $default; - } else { + if (InstallerUtil::$isInteractive) { // open the terminal and wait for feedback $stdin = fopen("php://stdin", "r"); @@ -564,6 +562,10 @@ public static function promptInput($prompt = "", $options = "", $default = "", $ $input = trim(fgets($stdin)); fclose($stdin); + } else { + + $input = $default; + } // check to see if it should be lowercased before sending back diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index aef2f2d4..3ea55311 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -22,6 +22,8 @@ class InstallerUtil { + public static $isInteractive; + /** * Move the component files from the package to their location in the patternlab-components dir * @param {String/Array} the items to create a fileList for @@ -583,8 +585,8 @@ protected static function removeDots($path) { */ protected static function packagesInstall($installerInfo, $event) { - print "arguments:"; - print_r($event->getArguments()); + // mark if this is an interactive call or not + self::$isInteractive = $event->getIO()->isInteractive(); // initialize a bunch of stuff like config and console self::init(); From 5d93175868f75febdbe55f819a31b8af7f25ba2b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 31 May 2016 14:10:54 -0400 Subject: [PATCH 309/436] be good if i was setting patternState --- src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 090894ab..b214e26e 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -51,6 +51,7 @@ public function run($type = "", $subtype = "") { $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternPartialCode"] = $patternStoreData["code"]; + $patternPartialData["patternState"] = $patternStoreData["state"]; $patternPartialData["patternLineageExists"] = isset($patternStoreData["lineages"]); $patternPartialData["patternLineages"] = isset($patternStoreData["lineages"]) ? $patternStoreData["lineages"] : array(); From 210a337964c676f26d0f7fd01b20b7b409537f7f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 1 Jun 2016 10:51:32 -0400 Subject: [PATCH 310/436] support for pattern subtype doc --- .../Exporters/PatternPartialsExporter.php | 15 +++++++++++++++ .../PatternData/Rules/DocumentationRule.php | 2 +- .../PatternData/Rules/PatternSubtypeRule.php | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index b214e26e..1fa71c99 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -86,6 +86,21 @@ public function run($type = "", $subtype = "") { } + } else if (($patternStoreData["category"] == "patternSubtype") && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { + + if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) { + + $patternPartialData = array(); + $patternPartialData["patternName"] = ucwords($patternStoreData["nameClean"]); + $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/index.html"; + $patternPartialData["patternPartial"] = $patternStoreData["partial"]; + $patternPartialData["patternSectionSubtype"] = isset($patternStoreData["descExists"]); + $patternPartialData["patternDesc"] = isset($patternStoreData["desc"]) ? $patternStoreData["desc"] : ""; + + $patternPartials[] = $patternPartialData; + + } + } } diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index d53bcb02..fd8327b9 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -92,7 +92,7 @@ public function run($depth, $ext, $path, $pathName, $name) { // if the pattern data store already exists make sure this data overwrites it $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; - PatternData::setOption($patternStoreKey, $patternStoreData); + PatternData::setOption($patternStoreKey, $patternStoreData); } diff --git a/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php b/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php index 395d1bae..fdb4e509 100644 --- a/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php +++ b/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php @@ -45,6 +45,8 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternSubtypePath = $pathName; // 00-atoms/02-blocks $patternSubtypePathDash = str_replace($dirSep,"-",$patternSubtypePath); // 00-atoms-02-blocks (file path) + $patternPartial = "viewall-".$patternTypeDash."-".$patternSubtypeDash; + // create a key for the data store $patternStoreKey = $patternTypeDash."-".$patternSubtypeDash."-plsubtype"; @@ -53,6 +55,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "name" => $patternSubtype, "nameDash" => $patternSubtypeDash, "nameClean" => $patternSubtypeClean, + "partial" => $patternPartial, "type" => $patternType, "typeDash" => $patternTypeDash, "breadcrumb" => $patternTypeClean, From 585924c97ce492810b12e355eb073d895eaee7ae Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Wed, 1 Jun 2016 11:26:32 -0700 Subject: [PATCH 311/436] Fixing Yaml Pseudo Pattern Parse Error --- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 7c1f7c89..f92b4b9f 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -129,7 +129,7 @@ public function run($depth, $ext, $path, $pathName, $name) { } else { try { - $patternDataBase = YAML::parse($file); + $patternDataBase = YAML::parse($data); } catch (ParseException $e) { printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); } From 2f625954fb86e629deaf0507842bd42de2f75488 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 14 Jun 2016 14:28:04 -0400 Subject: [PATCH 312/436] making breadcrumb an array --- .../PatternData/Rules/PatternRule.php | 4 ++-- .../PatternData/Rules/PatternSubtypeRule.php | 4 ++-- .../PatternData/Rules/PseudoPatternRule.php | 24 ++++++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index 010c65de..cb19c166 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -77,7 +77,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "nameClean" => $patternClean, "type" => $patternType, "typeDash" => $patternTypeDash, - "breadcrumb" => $patternTypeClean, + "breadcrumb" => array("patternType" => $patternTypeClean), "state" => $patternState, "hidden" => $hidden, "noviewall" => $noviewall, @@ -97,7 +97,7 @@ public function run($depth, $ext, $path, $pathName, $name) { if ($depth > 1) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; - $patternStoreData["breadcrumb"] = $patternTypeClean." > ".$patternSubtypeClean; + $patternStoreData["breadcrumb"] = array("patternType" => $patternTypeClean, "patternSubtype" => $patternSubtypeClean); } // if the pattern data store already exists make sure it is merged and overwrites this data diff --git a/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php b/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php index fdb4e509..1f26ff64 100644 --- a/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php +++ b/src/PatternLab/PatternData/Rules/PatternSubtypeRule.php @@ -45,7 +45,7 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternSubtypePath = $pathName; // 00-atoms/02-blocks $patternSubtypePathDash = str_replace($dirSep,"-",$patternSubtypePath); // 00-atoms-02-blocks (file path) - $patternPartial = "viewall-".$patternTypeDash."-".$patternSubtypeDash; + $patternPartial = "viewall-".$patternTypeDash."-".$patternSubtypeDash; // create a key for the data store $patternStoreKey = $patternTypeDash."-".$patternSubtypeDash."-plsubtype"; @@ -58,7 +58,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "partial" => $patternPartial, "type" => $patternType, "typeDash" => $patternTypeDash, - "breadcrumb" => $patternTypeClean, + "breadcrumb" => array("patternType" => $patternTypeClean), "depth" => $depth, "ext" => $ext, "path" => $path, diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 7c1f7c89..222f005c 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -37,12 +37,14 @@ public function __construct($options) { public function run($depth, $ext, $path, $pathName, $name) { // load default vars - $patternSubtype = PatternData::getPatternSubtype(); - $patternSubtypeDash = PatternData::getPatternSubtypeDash(); - $patternType = PatternData::getPatternType(); - $patternTypeDash = PatternData::getPatternTypeDash(); - $dirSep = PatternData::getDirSep(); - $frontMeta = PatternData::getFrontMeta(); + $patternSubtype = PatternData::getPatternSubtype(); + $patternSubtypeClean = PatternData::getPatternSubtypeClean(); + $patternSubtypeDash = PatternData::getPatternSubtypeDash(); + $patternType = PatternData::getPatternType(); + $patternTypeClean = PatternData::getPatternTypeClean(); + $patternTypeDash = PatternData::getPatternTypeDash(); + $dirSep = PatternData::getDirSep(); + $frontMeta = PatternData::getFrontMeta(); // should this pattern get rendered? $hidden = ($name[0] == "_"); @@ -95,7 +97,7 @@ public function run($depth, $ext, $path, $pathName, $name) { "nameClean" => $patternClean, "type" => $patternType, "typeDash" => $patternTypeDash, - "breadcrumb" => $patternType, + "breadcrumb" => array("patternType" => $patternTypeClean), "state" => $patternState, "hidden" => $hidden, "noviewall" => $noviewall, @@ -115,12 +117,12 @@ public function run($depth, $ext, $path, $pathName, $name) { if ($depth > 1) { $patternStoreData["subtype"] = $patternSubtype; $patternStoreData["subtypeDash"] = $patternSubtypeDash; - $patternStoreData["breadcrumb"] = $patternType." > ".$patternSubtype; + $patternStoreData["breadcrumb"] = array("patternType" => $patternTypeClean, "patternSubtype" => $patternSubtypeClean); } $patternDataBase = array(); - if (file_exists(Config::getOption("patternSourceDir")."/".$path."/".$patternBaseData)) { - $data = file_get_contents(Config::getOption("patternSourceDir")."/".$path."/".$patternBaseData); + if (file_exists(Config::getOption("patternSourceDir").DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$patternBaseData)) { + $data = file_get_contents(Config::getOption("patternSourceDir").DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$patternBaseData); if ($ext == "json") { $patternDataBase = json_decode($data,true); if ($jsonErrorMessage = JSON::hasError()) { @@ -144,7 +146,7 @@ public function run($depth, $ext, $path, $pathName, $name) { } // get the data for the pseudo-pattern - $data = file_get_contents(Config::getOption("patternSourceDir")."/".$pathName); + $data = file_get_contents(Config::getOption("patternSourceDir").DIRECTORY_SEPARATOR.$pathName); if ($ext == "json") { $patternData = json_decode($data,true); if ($jsonErrorMessage = JSON::hasError()) { From 09c63a6adf320acc6940b2939829f01ce63c8a71 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 14 Jun 2016 14:35:53 -0400 Subject: [PATCH 313/436] expanding config options and more dir separators --- src/PatternLab/Annotations.php | 18 +++++++------ src/PatternLab/Config.php | 26 ++++++++++--------- src/PatternLab/FileUtil.php | 10 +++---- .../PatternData/Helpers/RawPatternHelper.php | 2 +- .../PatternData/Rules/DocumentationRule.php | 6 ++--- src/PatternLab/Template.php | 20 +++++++------- src/PatternLab/Watcher.php | 25 +++++++++--------- 7 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 373c0ea8..0fe69460 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -40,7 +40,8 @@ public static function clear() { public static function gather() { // set-up default var - $sourceDir = Config::getOption("sourceDir"); + $annotationsDir = Config::getOption("annotationsDir"); + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); @@ -51,14 +52,14 @@ public static function gather() { self::$store["comments"] = array(); // iterate over all of the files in the annotations dir - if (!is_dir($sourceDir."/_annotations")) { - Console::writeWarning("_annotations/ doesn't exist so you won't have annotations..."); - mkdir($sourceDir."/_annotations"); + if (!is_dir($annotationsDir)) { + Console::writeWarning("".Console::getHumanReadablePath($annotationsDir)." doesn't exist so you won't have annotations..."); + mkdir($annotationsDir); } // find the markdown-based annotations $finder = new Finder(); - $finder->files()->name("*.md")->in($sourceDir."/_annotations"); + $finder->files()->name("*.md")->in($annotationsDir); $finder->sortByName(); foreach ($finder as $name => $file) { @@ -89,13 +90,14 @@ public static function gather() { } // read in the old style annotations.js, modify the data and generate JSON array to merge - if (file_exists($sourceDir."/_annotations/annotations.js")) { - $text = file_get_contents($sourceDir."/_annotations/annotations.js"); + $oldStyleAnnotationsPath = $annotationsDir.DIRECTORY_SEPARATOR."annotations.js"; + if (file_exists($oldStyleAnnotationsPath)) { + $text = file_get_contents($oldStyleAnnotationsPath); $text = str_replace("var comments = ","",$text); $text = rtrim($text,";"); $data = json_decode($text,true); if ($jsonErrorMessage = JSON::hasError()) { - JSON::lastErrorMsg("_annotations/annotations.js",$jsonErrorMessage,$data); + JSON::lastErrorMsg(Console::getHumanReadablePath($oldStyleAnnotationsPath),$jsonErrorMessage,$data); } } diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index c7b55203..4578b855 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -201,18 +201,20 @@ public static function init($baseDir = "", $verbose = true) { } // set-up the various dirs - self::$options["configDir"] = self::$userConfigDir; - self::$options["configPath"] = self::$userConfigPath; - self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; - self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; - self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; - self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts"; - self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source"; - self::$options["componentDir"] = self::$options["publicDir"]."/patternlab-components"; - self::$options["dataDir"] = self::$options["sourceDir"]."/_data"; - self::$options["patternExportDir"] = self::$options["exportDir"]."/patterns"; - self::$options["patternPublicDir"] = self::$options["publicDir"]."/patterns"; - self::$options["patternSourceDir"] = self::$options["sourceDir"]."/_patterns"; + self::$options["configDir"] = self::$userConfigDir; + self::$options["configPath"] = self::$userConfigPath; + self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core"; + self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports"; + self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public"; + self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts"; + self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source"; + self::$options["componentDir"] = isset(self::$options["componentDir"]) ? self::$options["publicDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["componentDir"]) : self::$options["publicDir"].DIRECTORY_SEPARATOR."patternlab-components"; + self::$options["dataDir"] = isset(self::$options["dataDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["dataDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_data"; + self::$options["patternExportDir"] = isset(self::$options["patternExportDir"]) ? self::$options["exportDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["patternExportDir"]) : self::$options["exportDir"].DIRECTORY_SEPARATOR."patterns"; + self::$options["patternPublicDir"] = isset(self::$options["patternPublicDir"]) ? self::$options["publicDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["patternPublicDir"]) : self::$options["publicDir"].DIRECTORY_SEPARATOR."patterns"; + self::$options["patternSourceDir"] = isset(self::$options["patternSourceDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["patternSourceDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_patterns"; + self::$options["metaDir"] = isset(self::$options["metaDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["metaDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_meta/"; + self::$options["annotationsDir"] = isset(self::$options["annotationsDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["annotationsDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_annotations/"; // handle a pre-2.1.0 styleguideKitPath before saving it if (isset(self::$options["styleguideKitPath"])) { diff --git a/src/PatternLab/FileUtil.php b/src/PatternLab/FileUtil.php index 1479e298..e1c5b8bb 100644 --- a/src/PatternLab/FileUtil.php +++ b/src/PatternLab/FileUtil.php @@ -210,13 +210,13 @@ public static function cleanPublic() { // scan source/ & public/ to figure out what directories might need to be cleaned up $publicDir = Config::getOption("publicDir"); $sourceDir = Config::getOption("sourceDir"); - $publicDirs = glob($publicDir."/*",GLOB_ONLYDIR); - $sourceDirs = glob($sourceDir."/*",GLOB_ONLYDIR); + $publicDirs = glob($publicDir.DIRECTORY_SEPARATOR."*",GLOB_ONLYDIR); + $sourceDirs = glob($sourceDir.DIRECTORY_SEPARATOR."*",GLOB_ONLYDIR); // make sure some directories aren't deleted $ignoreDirs = array("styleguide","patternlab-components"); foreach ($ignoreDirs as $ignoreDir) { - $key = array_search($publicDir."/".$ignoreDir,$publicDirs); + $key = array_search($publicDir.DIRECTORY_SEPARATOR.$ignoreDir,$publicDirs); if ($key !== false){ unset($publicDirs[$key]); } @@ -224,9 +224,9 @@ public static function cleanPublic() { // compare source dirs against public. remove those dirs w/ an underscore in source/ from the public/ list foreach ($sourceDirs as $dir) { - $cleanDir = str_replace($sourceDir."/","",$dir); + $cleanDir = str_replace($sourceDir.DIRECTORY_SEPARATOR,"",$dir); if ($cleanDir[0] == "_") { - $key = array_search($publicDir."/".str_replace("_","",$cleanDir),$publicDirs); + $key = array_search($publicDir.DIRECTORY_SEPARATOR.str_replace("_","",$cleanDir),$publicDirs); if ($key !== false){ unset($publicDirs[$key]); } diff --git a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php index cc201dc2..0c37facc 100644 --- a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php +++ b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php @@ -47,7 +47,7 @@ public function run() { $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; // load the raw data so it can be modified/rendered - $path = $patternSourceDir."/".$srcPath.".".$patternExtension; + $path = $patternSourceDir.DIRECTORY_SEPARATOR.$srcPath.".".$patternExtension; if (file_exists($path)) { PatternData::setPatternOption($patternStoreKey,"patternRaw",file_get_contents($path)); } else { diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index d53bcb02..0c982d96 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -54,7 +54,7 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternSourceDir = Config::getOption("patternSourceDir"); // parse data - $text = file_get_contents($patternSourceDir."/".$pathName); + $text = file_get_contents($patternSourceDir.DIRECTORY_SEPARATOR.$pathName); list($yaml,$markdown) = Documentation::parse($text); // grab the title and unset it from the yaml so it doesn't get duped in the meta @@ -67,8 +67,8 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternSubtypeDoc = false; if ($depth == 1) { // go through all of the directories to see if this one matches our doc - foreach (glob($patternSourceDir."/".$patternType."/*",GLOB_ONLYDIR) as $dir) { - $dir = str_replace($patternSourceDir."/".$patternType."/","",$dir); + foreach (glob($patternSourceDir.DIRECTORY_SEPARATOR.$patternType.DIRECTORY_SEPARATOR."*",GLOB_ONLYDIR) as $dir) { + $dir = str_replace($patternSourceDir.DIRECTORY_SEPARATOR.$patternType.DIRECTORY_SEPARATOR,"",$dir); if ($dir == $doc) { $patternSubtypeDoc = true; break; diff --git a/src/PatternLab/Template.php b/src/PatternLab/Template.php index 714f9389..7dc0aa87 100644 --- a/src/PatternLab/Template.php +++ b/src/PatternLab/Template.php @@ -42,7 +42,7 @@ public static function init() { // set-up config vars $patternExtension = Config::getOption("patternExtension"); - $sourceDir = Config::getOption("sourceDir"); + $metaDir = Config::getOption("metaDir"); $styleguideKit = Config::getOption("styleguideKit"); $styleguideKitPath = Config::getOption("styleguideKitPath"); @@ -51,15 +51,15 @@ public static function init() { } // load pattern-lab's resources - $partialPath = $styleguideKitPath."/views/partials"; - $generalHeaderPath = $partialPath."/general-header.".$patternExtension; - $generalFooterPath = $partialPath."/general-footer.".$patternExtension; - self::$htmlHead = (file_exists($generalHeaderPath)) ? file_get_contents($generalHeaderPath) : ""; - self::$htmlFoot = (file_exists($generalFooterPath)) ? file_get_contents($generalFooterPath) : ""; + $partialPath = $styleguideKitPath.DIRECTORY_SEPARATOR."views".DIRECTORY_SEPARATOR."partials"; + $generalHeaderPath = $partialPath.DIRECTORY_SEPARATOR."general-header.".$patternExtension; + $generalFooterPath = $partialPath.DIRECTORY_SEPARATOR."general-footer.".$patternExtension; + self::$htmlHead = (file_exists($generalHeaderPath)) ? file_get_contents($generalHeaderPath) : ""; + self::$htmlFoot = (file_exists($generalFooterPath)) ? file_get_contents($generalFooterPath) : ""; // gather the user-defined header and footer information - $patternHeadPath = $sourceDir."/_meta/_00-head.".$patternExtension; - $patternFootPath = $sourceDir."/_meta/_01-foot.".$patternExtension; + $patternHeadPath = $metaDir.DIRECTORY_SEPARATOR."_00-head.".$patternExtension; + $patternFootPath = $metaDir.DIRECTORY_SEPARATOR."_01-foot.".$patternExtension; self::$patternHead = (file_exists($patternHeadPath)) ? file_get_contents($patternHeadPath) : ""; self::$patternFoot = (file_exists($patternFootPath)) ? file_get_contents($patternFootPath) : ""; @@ -68,8 +68,8 @@ public static function init() { $filesystemLoaderClass = $patternEngineBasePath."\Loaders\FilesystemLoader"; $options = array(); - $options["templatePath"] = $styleguideKitPath."/views"; - $options["partialsPath"] = $styleguideKitPath."/views/partials"; + $options["templatePath"] = $styleguideKitPath.DIRECTORY_SEPARATOR."views"; + $options["partialsPath"] = $options["templatePath"].DIRECTORY_SEPARATOR."partials"; self::$filesystemLoader = new $filesystemLoaderClass($options); diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index a7b93e80..8c0a6e9a 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -65,7 +65,7 @@ public function watch($options = array()) { // DEPRECATED /*if ($reload) { $path = str_replace("lib".DIRECTORY_SEPARATOR."PatternLab","autoReloadServer.php",__DIR__); - $fp = popen("php ".$path." -s", "r"); + $fp = popen("php ".$path." -s", "r"); Console::writeLine("starting page auto-reload..."); }*/ @@ -82,11 +82,12 @@ public function watch($options = array()) { Console::writeLine("watching your site for changes..."); // default vars - $publicDir = Config::getOption("publicDir"); - $sourceDir = Config::getOption("sourceDir"); - $ignoreExts = Config::getOption("ie"); - $ignoreDirs = Config::getOption("id"); - $patternExt = Config::getOption("patternExtension"); + $publicDir = Config::getOption("publicDir"); + $sourceDir = Config::getOption("sourceDir"); + $patternSourceDir = Config::getOption("patternSourceDir"); + $ignoreExts = Config::getOption("ie"); + $ignoreDirs = Config::getOption("id"); + $patternExt = Config::getOption("patternExtension"); // run forever while (true) { @@ -95,7 +96,7 @@ public function watch($options = array()) { $cp = clone $o->patterns; // iterate over the patterns & related data and regenerate the entire site if they've changed - $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir."/_patterns/"), \RecursiveIteratorIterator::SELF_FIRST); + $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($patternSourceDir), \RecursiveIteratorIterator::SELF_FIRST); // make sure dots are skipped $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS); @@ -103,7 +104,7 @@ public function watch($options = array()) { foreach($patternObjects as $name => $object) { // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored - $fileName = str_replace($sourceDir."/_patterns".DIRECTORY_SEPARATOR,"",$name); + $fileName = str_replace($patternSourceDir.DIRECTORY_SEPARATOR,"",$name); $fileNameClean = str_replace(DIRECTORY_SEPARATOR."_",DIRECTORY_SEPARATOR,$fileName); if ($object->isFile() && (($object->getExtension() == $patternExt) || ($object->getExtension() == "json") || ($object->getExtension() == "md"))) { @@ -168,10 +169,10 @@ public function watch($options = array()) { } // iterate over annotations, data, meta and any other _ dirs - $watchDirs = glob($sourceDir."/_*",GLOB_ONLYDIR); + $watchDirs = glob($sourceDir.DIRECTORY_SEPARATOR."_*",GLOB_ONLYDIR); foreach ($watchDirs as $watchDir) { - if (str_replace($sourceDir."/","",$watchDir) != "_patterns") { + if ($watchDir != $patternSourceDir) { // iterate over the data files and regenerate the entire site if they've changed $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($watchDir), \RecursiveIteratorIterator::SELF_FIRST); @@ -181,7 +182,7 @@ public function watch($options = array()) { foreach($objects as $name => $object) { - $fileName = str_replace($sourceDir."/","",$name); + $fileName = str_replace($sourceDir.DIRECTORY_SEPARATOR,"",$name); $mt = $object->getMTime(); if (!isset($o->$fileName)) { @@ -205,7 +206,7 @@ public function watch($options = array()) { // iterate over all of the other files in the source directory and move them if their modified time has changed if ($moveStatic) { - $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir."/"), \RecursiveIteratorIterator::SELF_FIRST); + $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir.DIRECTORY_SEPARATOR), \RecursiveIteratorIterator::SELF_FIRST); // make sure dots are skipped $objects->setFlags(\FilesystemIterator::SKIP_DOTS); From 509baa904892b711109d1fb15ae727bb40caff91 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 16 Jun 2016 15:15:04 -0400 Subject: [PATCH 314/436] adding ArrayFinder requirement --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 691c8eea..2effb682 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ } }, "require": { - "php": ">=5.3.6", + "php": ">=5.4", "michelf/php-markdown": "~1.5", "seld/jsonlint": "~1.3", "symfony/event-dispatcher": "~2.6", @@ -36,6 +36,7 @@ "symfony/finder": "~2.6", "symfony/yaml": "~2.6", "kevinlebrun/colors.php": "~0.4.1", - "alchemy/zippy": "~0.2.1" + "alchemy/zippy": "~0.2.1", + "shudrum/array-finder": "^1.0.0" } } From a29ce4a97a9ac5cca548c33b5ae013fd88929c0b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 16 Jun 2016 15:15:53 -0400 Subject: [PATCH 315/436] adding support for ArrayFinder, renaming updateOption to setOption, reorganizing initial set-up --- src/PatternLab/Config.php | 116 ++++++++++++-------------------------- 1 file changed, 36 insertions(+), 80 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 4578b855..bc37ecaa 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -15,6 +15,7 @@ use \PatternLab\Console; use \PatternLab\FileUtil; use \PatternLab\Timer; +use \Shudrum\Component\ArrayFinder\ArrayFinder; use \Symfony\Component\Yaml\Yaml; use \Symfony\Component\Yaml\Exception\ParseException; @@ -53,14 +54,11 @@ protected static function cleanDir($dir) { * * @return {String/Boolean} the value of the get or false if it wasn't found */ - public static function getOption($optionName = "") { + public static function getOption($key = "") { - if (empty($optionName)) { - return false; - } - - if (array_key_exists($optionName,self::$options)) { - return self::$options[$optionName]; + if (!empty($key)) { + $arrayFinder = new ArrayFinder(self::$options); + return $arrayFinder->get($key); } return false; @@ -138,46 +136,44 @@ public static function init($baseDir = "", $verbose = true) { mkdir(self::$userConfigDir); } + // check to see if the user config exists, if not create it + if ($verbose) { + Console::writeLine("configuring pattern lab..."); + } + // make sure migrate doesn't happen by default - $migrate = false; - $diffVersion = false; + $migrate = false; + $diffVersion = false; + $defaultOptions = array(); + $userOptions = array(); // double-check the default config file exists if (!file_exists(self::$plConfigPath)) { - Console::writeError("make sure ".self::$plConfigPath." exists before trying to have Pattern Lab build the config.yml file automagically..."); + Console::writeError("the default options for Pattern Lab don't seem to exist at ".Console::getHumanReadablePath(self::$plConfigPath).". please check on the install location of pattern lab..."); } // set the default config using the pattern lab config try { - $data = Yaml::parse(file_get_contents(self::$plConfigPath)); + $defaultOptions = Yaml::parse(file_get_contents(self::$plConfigPath)); + $defaultOptions = array_merge(self::$options, $defaultOptions); } catch (ParseException $e) { - Console::writeError("Config parse error in ".self::$plConfigPath.": ".$e->getMessage()); - } - - // load the options from the default file - self::loadOptions($data); - - // make sure these are copied - $defaultOptions = self::$options; - - // check to see if the user config exists, if not create it - if ($verbose) { - Console::writeLine("configuring pattern lab..."); + Console::writeError("Config parse error in ".Console::getHumanReadablePath(self::$plConfigPath).": ".$e->getMessage()); } - if (!file_exists(self::$userConfigPath)) { - $migrate = true; - } else { + // double-check the user's config exists. if not mark that we should migrate the default one + if (file_exists(self::$userConfigPath)) { try { - $data = Yaml::parse(file_get_contents(self::$userConfigPath)); + $userOptions = Yaml::parse(file_get_contents(self::$userConfigPath)); + self::$options = array_merge(self::$options, $userOptions); } catch (ParseException $e) { - Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); + Console::writeError("Config parse error in ".Console::getHumanReadablePath(self::$userConfigPath).": ".$e->getMessage()); } - self::loadOptions($data); + } else { + $migrate = true; } // compare version numbers - $diffVersion = (self::$options["v"] != $defaultOptions["v"]) ? true : false; + $diffVersion = (isset($userOptions["v"]) && ($userOptions["v"] == $defaultOptions["v"])) ? false : true; // run an upgrade and migrations if necessary if ($migrate || $diffVersion) { @@ -190,7 +186,7 @@ public static function init($baseDir = "", $verbose = true) { exit; } } else { - self::$options = self::writeNewConfigFile(self::$options,$defaultOptions); + self::$options = self::writeNewConfigFile(self::$options, $defaultOptions); } } @@ -256,29 +252,6 @@ protected static function isAssoc($array) { return (bool) count(array_filter(array_keys($array), 'is_string')); } - /** - * Load the options into self::$options - * @param {Array} the data to be added - * @param {String} any addition that may need to be added to the option key - */ - public static function loadOptions($data,$parentKey = "") { - - foreach ($data as $key => $value) { - - $key = $parentKey.trim($key); - - if (is_array($value) && self::isAssoc($value)) { - self::loadOptions($value,$key."."); - } else if (is_array($value) && !self::isAssoc($value)) { - self::$options[$key] = $value; - } else { - self::$options[$key] = trim($value); - } - - } - - } - /** * Add an option and associated value to the base Config * @param {String} the name of the option to be added @@ -292,12 +265,9 @@ public static function setOption($optionName = "", $optionValue = "") { return false; } - if (!array_key_exists($optionName,self::$options)) { - self::$options[$optionName] = $optionValue; - return true; - } - - return false; + $arrayFinder = new ArrayFinder(self::$options); + $arrayFinder->set($key, $value); + self::$options = $arrayFinder->get(); } @@ -377,29 +347,15 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal } /** - * Update an option and associated value to the base Config - * @param {String} the name of the option to be updated - * @param {String} the value of the option to be updated + * Add an option and associated value to the base Config. BC wrap for setOption + * @param {String} the name of the option to be added + * @param {String} the value of the option to be added * - * @return {Boolean} whether the update was successful + * @return {Boolean} whether the set was successful */ public static function updateOption($optionName = "", $optionValue = "") { - if (empty($optionName) || empty($optionValue)) { - return false; - } - - if (array_key_exists($optionName,self::$options)) { - if (is_array(self::$options[$optionName])) { - $optionValue = is_array($optionValue) ? $optionValue : array($optionValue); - self::$options[$optionName] = array_merge(self::$options[$optionName], $optionValue); - } else { - self::$options[$optionName] = $optionValue; - } - return true; - } - - return false; + return self::setOption($optionName, $optionValue); } @@ -425,7 +381,7 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { } // reload the options - self::loadOptions($options); + self::$options = $options; // dump the YAML $configOutput = Yaml::dump($options, 3); From 0a1b454b52429185bce3bb1bf9fb7fe38d32868c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 16 Jun 2016 15:16:21 -0400 Subject: [PATCH 316/436] switching to setOption --- src/PatternLab/Generator.php | 2 +- src/PatternLab/Watcher.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index 6408fac7..2b1d3b54 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -56,7 +56,7 @@ public function generate($options = array()) { $watchVerbose = (isset($options["watchVerbose"])) ? $options["watchVerbose"] : false; if ($noCacheBuster) { - Config::updateOption("cacheBuster",0); + Config::setOption("cacheBuster",0); } // gather up all of the data to be used in patterns diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 8c0a6e9a..e304bec9 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -70,7 +70,7 @@ public function watch($options = array()) { }*/ if ($noCacheBuster) { - Config::updateOption("cacheBuster",0); + Config::setOption("cacheBuster",0); } $c = false; // track that one loop through the pattern file listing has completed From 56b2093cc616227411bed7083790aced3e5c0003 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 16 Jun 2016 15:17:08 -0400 Subject: [PATCH 317/436] adding support for ArrayFinder --- src/PatternLab/Data.php | 49 ++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index 732d295d..e0da3fc7 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -16,6 +16,7 @@ use \PatternLab\Console; use \PatternLab\Dispatcher; use \PatternLab\Timer; +use \Shudrum\Component\ArrayFinder\ArrayFinder; use \Symfony\Component\Finder\Finder; use \Symfony\Component\Yaml\Exception\ParseException; use \Symfony\Component\Yaml\Yaml; @@ -198,6 +199,8 @@ public static function get() { return self::$store; } + + /** * Generate the listItems array * @param {String} the filename for the pattern to be parsed @@ -274,20 +277,19 @@ public static function getListItems($filepath,$ext = "json") { return $listItems; } - + /** - * Return the value for an option + * Get an option for the data store + * @param {String} a string in dot notation dictating where the option is in the data structure * - * @return {String} the value of the option requested + * @return {Array} the store */ - public static function getOption($optionName) { - - if (isset(self::$store[$optionName])) { - return self::$store[$optionName]; + public static function getOption($key = "") { + if (!empty($key)) { + $arrayFinder = new ArrayFinder(self::$store); + return $arrayFinder->get($key); } - return false; - } /** @@ -359,7 +361,34 @@ public static function initPattern($optionName) { public static function printData() { print_r(self::$store); } - + + /** + * Replace the data store + * @param {Array} the new store + */ + public static function replaceStore($store) { + self::$store = $store; + } + + /** + * Set an option for the data store + * @param {String} a string in dot notation dictating where the option is in the data structure + * @param {Mixed} the value for the key + * + * @return {Array} the store + */ + public static function setOption($key = "", $value = "") { + + if (empty($key)) { + return false; + } + + $arrayFinder = new ArrayFinder(self::$store); + $arrayFinder->set($key, $value); + self::$store = $arrayFinder->get(); + + } + /** * Set an option on a sub element of the data array * @param {String} name of the option From 0a10e542b11a5cbc62a48e6db222ad8af56dc8d6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 17 Jun 2016 23:39:06 -0400 Subject: [PATCH 318/436] fixing reverse lineage so it shows state --- src/PatternLab/PatternData/Helpers/PatternStateHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php index 914d649b..e8fd2b5c 100644 --- a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php @@ -112,7 +112,7 @@ public function run() { $lineagePattern = $patternLineageInfo["lineagePattern"]; $patternState = PatternData::getPatternOption($lineagePattern,"state"); if (($patternState != "") && ($patternState != null)) { - PatternData::setPatternSubOption($patternStoreKey,"lineages",$patternLineageKey,"lineageState",$patternState); + PatternData::setPatternSubOption($patternStoreKey,"lineagesR",$patternLineageKey,"lineageState",$patternState); } } From 94f4ac6a298b01ea4915cd7eb2fa6398fe5d9297 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 17 Jun 2016 23:57:17 -0400 Subject: [PATCH 319/436] minor fixes for setting config options --- src/PatternLab/Config.php | 18 ++++++------------ .../Console/Commands/ConfigCommand.php | 3 ++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index bc37ecaa..1b0a09f2 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -266,7 +266,7 @@ public static function setOption($optionName = "", $optionValue = "") { } $arrayFinder = new ArrayFinder(self::$options); - $arrayFinder->set($key, $value); + $arrayFinder->set($optionName, $optionValue); self::$options = $arrayFinder->get(); } @@ -323,7 +323,8 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal } else if (self::$options["overrideConfig"] == "q") { // standardize the values for comparison - $currentOptionValue = is_array(self::$options[$optionName]) ? implode(", ",self::$options[$optionName]) : self::$options[$optionName]; + $currentOption = self::getOption($optionName); + $currentOptionValue = is_array($currentOption) ? implode(", ",$currentOption) : $currentOption; $newOptionValue = is_array($optionValue) ? implode(", ",$optionValue) : $optionValue; if ($currentOptionValue != $newOptionValue) { @@ -373,18 +374,11 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); } - if (isset($options[$optionName]) && is_array($options[$optionName])) { - $optionValue = is_array($optionValue) ? $optionValue : array($optionValue); - $options[$optionName] = array_merge($options[$optionName], $optionValue); - } else { - $options[$optionName] = $optionValue; - } - - // reload the options - self::$options = $options; + print "foo ".$optionName." ".$optionValue; + self::setOption($optionName, $optionValue); // dump the YAML - $configOutput = Yaml::dump($options, 3); + $configOutput = Yaml::dump(self::$options, 3); // write out the new config file file_put_contents(self::$userConfigPath,$configOutput); diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index 2df58b90..a0fc0c92 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -77,7 +77,7 @@ public function run() { $updateOptionBits = explode("=",$updateOption); if (count($updateOptionBits) == 1) { Console::writeError("the --set value should look like optionName=\"optionValue\". nothing was updated..."); - } + } // set the name and value that were passed $updateName = $updateOptionBits[0]; @@ -90,6 +90,7 @@ public function run() { Console::writeError("the --set option you provided, ".$updateName.", does not exists in the config. nothing will be updated..."); } else { Config::updateConfigOption($updateName,$updateValue); + Console::writeInfo("config option updated..."); } } else { From a1b53dcfeeadc659863cdc0b49684ae442d9e1ec Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 18 Jun 2016 09:26:38 -0400 Subject: [PATCH 320/436] reworking the config --- src/PatternLab/Config.php | 9 +- .../Console/Commands/ConfigCommand.php | 151 ++++++++++++------ 2 files changed, 107 insertions(+), 53 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 1b0a09f2..f855bff0 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -374,11 +374,16 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) { Console::writeError("Config parse error in ".self::$userConfigPath.": ".$e->getMessage()); } - print "foo ".$optionName." ".$optionValue; + // set this option for the current running of the app self::setOption($optionName, $optionValue); + // modify the yaml file results + $arrayFinder = new ArrayFinder($options); + $arrayFinder->set($optionName, $optionValue); + $options = $arrayFinder->get(); + // dump the YAML - $configOutput = Yaml::dump(self::$options, 3); + $configOutput = Yaml::dump($options, 3); // write out the new config file file_put_contents(self::$userConfigPath,$configOutput); diff --git a/src/PatternLab/Console/Commands/ConfigCommand.php b/src/PatternLab/Console/Commands/ConfigCommand.php index a0fc0c92..820a3f13 100644 --- a/src/PatternLab/Console/Commands/ConfigCommand.php +++ b/src/PatternLab/Console/Commands/ConfigCommand.php @@ -15,9 +15,12 @@ use \PatternLab\Console\Command; use \PatternLab\Generator; use \PatternLab\Timer; +use \Shudrum\Component\ArrayFinder\ArrayFinder; class ConfigCommand extends Command { + private $lengthLong; + public function __construct() { parent::__construct(); @@ -35,68 +38,114 @@ public function run() { if (Console::findCommandOption("list")) { - // get all of the options - $options = Config::getOptions(); - - // sort 'em alphabetically - ksort($options); - - // find length of longest option - $lengthLong = 0; - foreach ($options as $optionName => $optionValue) { - $lengthLong = (strlen($optionName) > $lengthLong) ? strlen($optionName) : $lengthLong; - } - - // iterate over each option and spit it out - foreach ($options as $optionName => $optionValue) { - $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; - $optionValue = (!$optionValue) ? "false" : $optionValue; - $spacer = Console::getSpacer($lengthLong,strlen($optionName)); - Console::writeLine("".$optionName.":".$spacer.$optionValue); - } + $this->listOptions(); } else if (Console::findCommandOption("get")) { - // figure out which optino was passed - $searchOption = Console::findCommandOptionValue("get"); - $optionValue = Config::getOption($searchOption); - - // write it out - if (!$optionValue) { - Console::writeError("the --get value you provided, ".$searchOption.", does not exists in the config..."); - } else { - $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; - $optionValue = (!$optionValue) ? "false" : $optionValue; - Console::writeInfo($searchOption.": ".$optionValue.""); - } + $this->getOption(); } else if (Console::findCommandOption("set")) { - // find the value that was passed - $updateOption = Console::findCommandOptionValue("set"); - $updateOptionBits = explode("=",$updateOption); - if (count($updateOptionBits) == 1) { - Console::writeError("the --set value should look like optionName=\"optionValue\". nothing was updated..."); - } - - // set the name and value that were passed - $updateName = $updateOptionBits[0]; - $updateValue = (($updateOptionBits[1][0] == "\"") || ($updateOptionBits[1][0] == "'")) ? substr($updateOptionBits[1],1,strlen($updateOptionBits[1])-1) : $updateOptionBits[1]; + $this->setOption(); - // make sure the option being updated already exists - $currentValue = Config::getOption($updateName); + } else { - if (!$currentValue) { - Console::writeError("the --set option you provided, ".$updateName.", does not exists in the config. nothing will be updated..."); - } else { - Config::updateConfigOption($updateName,$updateValue); - Console::writeInfo("config option updated..."); - } + Console::writeHelpCommand($this->command); + } + + } + + /** + * Get the given option and return its value + */ + private function getOption() { + + // figure out which option was passed + $searchOption = Console::findCommandOptionValue("get"); + $optionValue = Config::getOption($searchOption); + + // write it out + if (!$optionValue) { + Console::writeError("the --get value you provided, ".$searchOption.", does not exists in the config..."); + } else { + $optionValue = (is_array($optionValue)) ? implode(", ",$optionValue) : $optionValue; + $optionValue = (!$optionValue) ? "false" : $optionValue; + Console::writeInfo($searchOption.": ".$optionValue.""); + } + + } + + /** + * List out of the options available in the config + */ + private function listOptions() { + + // get all of the options + $options = Config::getOptions(); + + // sort 'em alphabetically + ksort($options); + + // find length of longest option + $this->lengthLong = 0; + foreach ($options as $optionName => $optionValue) { + $this->lengthLong = (strlen($optionName) > $this->lengthLong) ? strlen($optionName) : $this->lengthLong; + } + + $this->writeOutOptions($options); + + } + + /** + * Set the given option to the given value + */ + protected function setOption() { + + // find the value that was passed + $updateOption = Console::findCommandOptionValue("set"); + $updateOptionBits = explode("=",$updateOption); + if (count($updateOptionBits) == 1) { + Console::writeError("the --set value should look like optionName=\"optionValue\". nothing was updated..."); + } + + // set the name and value that were passed + $updateName = $updateOptionBits[0]; + $updateValue = (($updateOptionBits[1][0] == "\"") || ($updateOptionBits[1][0] == "'")) ? substr($updateOptionBits[1],1,strlen($updateOptionBits[1])-1) : $updateOptionBits[1]; + + // make sure the option being updated already exists + $currentValue = Config::getOption($updateName); + + if (!$currentValue) { + Console::writeError("the --set option you provided, ".$updateName.", does not exists in the config. nothing will be updated..."); } else { + Config::updateConfigOption($updateName,$updateValue); + Console::writeInfo("config option updated..."); + } + + } + + /** + * Write out the given options. Check to see if it's a nested sequential or associative array + * @param {Mixed} the options to check and write out + * @param {String} copy to be added to the beginning of the option if nested + */ + private function writeOutOptions($options, $pre = "") { + + foreach ($options as $optionName => $optionValue) { - // no acceptable options were passed so write out the help - Console::writeHelpCommand($this->command); + if (is_array($optionValue) && (count($optionValue) > 0) && !isset($optionValue[0])) { + + $this->writeOutOptions($optionValue, $optionName."."); + + } else { + + $optionValue = (is_array($optionValue) && isset($optionValue[0])) ? implode(", ",$optionValue) : $optionValue; + $optionValue = (!$optionValue) ? "false" : $optionValue; + $spacer = Console::getSpacer($this->lengthLong,strlen($pre.$optionName)); + Console::writeLine("".$pre.$optionName.":".$spacer.$optionValue); + + } } From 4e6c4f74011cba0a6a4cfd315c77d79b61df8c1b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 18 Jun 2016 10:32:35 -0400 Subject: [PATCH 321/436] cleaning some of the output and properly setting subtype --- .../Exporters/PatternPartialsExporter.php | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 3c9e7288..b3f1ea37 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -47,7 +47,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = ucwords($patternStoreData["nameClean"]); + $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternPartialCode"] = $patternStoreData["code"]; @@ -65,22 +65,17 @@ public function run($type = "", $subtype = "") { $patternPartialData["patternDescAdditions"] = isset($patternStoreData["partialViewDescAdditions"]) ? $patternStoreData["partialViewDescAdditions"] : array(); $patternPartialData["patternExampleAdditions"] = isset($patternStoreData["partialViewExampleAdditions"]) ? $patternStoreData["partialViewExampleAdditions"] : array(); - //$patternPartialData["patternCSSExists"] = Config::$options["enableCSS"]; - $patternPartialData["patternCSSExists"] = false; - // add the pattern data so it can be exported - $patternData = array(); - //$patternFooterData["patternFooterData"]["cssEnabled"] = (Config::$options["enableCSS"] && isset($this->patternCSS[$p])) ? "true" : "false"; - $patternData["cssEnabled"] = false; - $patternData["lineage"] = isset($patternStoreData["lineages"]) ? $patternStoreData["lineages"] : array(); - $patternData["lineageR"] = isset($patternStoreData["lineagesR"]) ? $patternStoreData["lineagesR"] : array(); - $patternData["patternBreadcrumb"] = $patternStoreData["breadcrumb"]; - $patternData["patternDesc"] = (isset($patternStoreData["desc"])) ? $patternStoreData["desc"] : ""; - $patternData["patternExtension"] = ".mustache"; - $patternData["patternName"] = $patternStoreData["nameClean"]; - $patternData["patternPartial"] = $patternStoreData["partial"]; - $patternData["patternState"] = $patternStoreData["state"]; - $patternPartialData["patternData"] = json_encode($patternData); + $patternData = array(); + $patternData["lineage"] = isset($patternStoreData["lineages"]) ? $patternStoreData["lineages"] : array(); + $patternData["lineageR"] = isset($patternStoreData["lineagesR"]) ? $patternStoreData["lineagesR"] : array(); + $patternData["patternBreadcrumb"] = $patternStoreData["breadcrumb"]; + $patternData["patternDesc"] = (isset($patternStoreData["desc"])) ? $patternStoreData["desc"] : ""; + $patternData["patternExtension"] = Config::getOption("patternExtension"); + $patternData["patternName"] = $patternStoreData["nameClean"]; + $patternData["patternPartial"] = $patternStoreData["partial"]; + $patternData["patternState"] = $patternStoreData["state"]; + $patternPartialData["patternData"] = json_encode($patternData); $patternPartials[] = $patternPartialData; @@ -91,10 +86,10 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = ucwords($patternStoreData["nameClean"]); + $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/index.html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; - $patternPartialData["patternSectionSubtype"] = isset($patternStoreData["descExists"]); + $patternPartialData["patternSectionSubtype"] = true; $patternPartialData["patternDesc"] = isset($patternStoreData["desc"]) ? $patternStoreData["desc"] : ""; $patternPartials[] = $patternPartialData; From c546e24498f8d00140e9a4d6606e4734eb04688d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 18 Jun 2016 15:14:01 -0400 Subject: [PATCH 322/436] adding support for defaultPattern --- config/config.yml.default | 3 +++ src/PatternLab/Config.php | 1 + 2 files changed, 4 insertions(+) diff --git a/config/config.yml.default b/config/config.yml.default index b7094043..84dd167d 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -37,3 +37,6 @@ cacheBusterOn: "true" exportDir: "export" publicDir: "public" sourceDir: "source" + +# defaultPattern to show on load +defaultPattern: "all" diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index f855bff0..e5872fe4 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -235,6 +235,7 @@ public static function init($baseDir = "", $verbose = true) { // which of these should be exposed in the front-end? self::$options["exposedOptions"] = array(); self::setExposedOption("cacheBuster"); + self::setExposedOption("defaultPattern"); self::setExposedOption("ishFontSize"); self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); From 69475a0924be61e394d5b6237ee80d1d288cd182 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 18 Jun 2016 15:14:36 -0400 Subject: [PATCH 323/436] pushing the internal version number to the correct version --- config/config.yml.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml.default b/config/config.yml.default index 84dd167d..44c1ef85 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -1,7 +1,7 @@ ## Configuration Options for Pattern Lab # pattern lab version -v: "2.0.0-DP1" +v: "2.2.1" # what to do when included config var conflicts, q for question, a for always override, n for never override overrideConfig: "q" From 9537dc5c655e4755b0a7fe71ff5d0fdda605dd93 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 18 Jun 2016 15:31:42 -0400 Subject: [PATCH 324/436] sanity check on old style annotations --- src/PatternLab/Annotations.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 0fe69460..c6288c3d 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -94,7 +94,9 @@ public static function gather() { if (file_exists($oldStyleAnnotationsPath)) { $text = file_get_contents($oldStyleAnnotationsPath); $text = str_replace("var comments = ","",$text); - $text = rtrim($text,";"); + if ($text[strlen($text)-1] == ";") { + $text = rtrim($text,";"); + } $data = json_decode($text,true); if ($jsonErrorMessage = JSON::hasError()) { JSON::lastErrorMsg(Console::getHumanReadablePath($oldStyleAnnotationsPath),$jsonErrorMessage,$data); From 2a4350df9bd9e76258a74236a44a17334fbcc5d6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 19 Jun 2016 10:46:03 -0400 Subject: [PATCH 325/436] adding support for defaultShowPatternInfo --- config/config.yml.default | 3 +++ src/PatternLab/Config.php | 1 + 2 files changed, 4 insertions(+) diff --git a/config/config.yml.default b/config/config.yml.default index 44c1ef85..5751dee2 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -40,3 +40,6 @@ sourceDir: "source" # defaultPattern to show on load defaultPattern: "all" + +# show pattern info by default on the "view all" views +defaultShowPatternInfo: true diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index e5872fe4..7b1710db 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -236,6 +236,7 @@ public static function init($baseDir = "", $verbose = true) { self::$options["exposedOptions"] = array(); self::setExposedOption("cacheBuster"); self::setExposedOption("defaultPattern"); + self::setExposedOption("defaultShowPatternInfo"); self::setExposedOption("ishFontSize"); self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); From 4d9fdd3c9ef64b75a13f7e13a12f6bfa0662c128 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 19 Jun 2016 21:01:56 -0400 Subject: [PATCH 326/436] fixing whitespace --- composer.json | 80 +++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 2effb682..51dee349 100644 --- a/composer.json +++ b/composer.json @@ -1,42 +1,42 @@ { - "name": "pattern-lab/core", - "description": "The core functionality for Pattern Lab.", - "keywords": ["pattern lab", "styleguide", "style guide", "atomic", "atomic design"], - "homepage": "http://patternlab.io", - "license": "MIT", - "authors": [ - { - "name": "Dave Olsen", - "email": "dmolsen@gmail.com", - "homepage": "http://dmolsen.com", - "role": "Lead Developer" - }, - { - "name": "Brad Frost", - "homepage": "http://bradfrostweb.com", - "role": "Creator" - } - ], - "support": { - "issues": "https://github.com/pattern-lab/patternlab-php-core/issues", - "wiki": "http://patternlab.io/docs/", - "source": "https://github.com/pattern-lab/patternlab-php-core/releases" - }, - "autoload": { - "psr-0": { - "PatternLab": "src/" - } - }, - "require": { - "php": ">=5.4", - "michelf/php-markdown": "~1.5", - "seld/jsonlint": "~1.3", - "symfony/event-dispatcher": "~2.6", - "symfony/filesystem": "~2.6.4", - "symfony/finder": "~2.6", - "symfony/yaml": "~2.6", - "kevinlebrun/colors.php": "~0.4.1", - "alchemy/zippy": "~0.2.1", - "shudrum/array-finder": "^1.0.0" - } + "name": "pattern-lab/core", + "description": "The core functionality for Pattern Lab.", + "keywords": ["pattern lab", "styleguide", "style guide", "atomic", "atomic design"], + "homepage": "http://patternlab.io", + "license": "MIT", + "authors": [ + { + "name": "Dave Olsen", + "email": "dmolsen@gmail.com", + "homepage": "http://dmolsen.com", + "role": "Lead Developer" + }, + { + "name": "Brad Frost", + "homepage": "http://bradfrostweb.com", + "role": "Creator" + } + ], + "support": { + "issues": "https://github.com/pattern-lab/patternlab-php-core/issues", + "wiki": "http://patternlab.io/docs/", + "source": "https://github.com/pattern-lab/patternlab-php-core/releases" + }, + "autoload": { + "psr-0": { + "PatternLab": "src/" + } + }, + "require": { + "php": ">=5.4", + "michelf/php-markdown": "~1.5", + "seld/jsonlint": "~1.3", + "symfony/event-dispatcher": "~2.6", + "symfony/filesystem": "~2.6.4", + "symfony/finder": "~2.6", + "symfony/yaml": "~2.6", + "kevinlebrun/colors.php": "~0.4.1", + "alchemy/zippy": "~0.2.1", + "shudrum/array-finder": "^1.0.0" + } } From 4c8615015f1cdb3490884ab2327e384bff0ec8ba Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 19 Jun 2016 21:06:16 -0400 Subject: [PATCH 327/436] adding badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index eb6ef7e4..e341c723 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +![license](https://img.shields.io/github/license/pattern-lab/patternlab-php-core.svg?maxAge=2592000) +[![Packagist](https://img.shields.io/packagist/v/pattern-lab/core.svg?maxAge=2592000)](https://packagist.org/packages/pattern-lab/core) [![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg?maxAge=2592000)](https://gitter.im/pattern-lab/php) + # Pattern Lab Core This repository contains the core functionality for Pattern Lab. Pattern Lab Core is designed to be included as a dependency within Editions. Turn it up. From 7cb258e7feeabb0ba5dca21d4fa15de2461a892c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 19 Jun 2016 21:25:47 -0400 Subject: [PATCH 328/436] fixing the config init --- src/PatternLab/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 7b1710db..64aba3b0 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -155,7 +155,7 @@ public static function init($baseDir = "", $verbose = true) { // set the default config using the pattern lab config try { $defaultOptions = Yaml::parse(file_get_contents(self::$plConfigPath)); - $defaultOptions = array_merge(self::$options, $defaultOptions); + self::$options = array_merge(self::$options, $defaultOptions); } catch (ParseException $e) { Console::writeError("Config parse error in ".Console::getHumanReadablePath(self::$plConfigPath).": ".$e->getMessage()); } From d89cf54e9648b7f063b20c7cab81a62c7a9c05b7 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 20 Jun 2016 21:30:03 -0400 Subject: [PATCH 329/436] making sure their are no extraneous lines at the end of an annotations file --- src/PatternLab/Annotations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index c6288c3d..465ee551 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -92,7 +92,7 @@ public static function gather() { // read in the old style annotations.js, modify the data and generate JSON array to merge $oldStyleAnnotationsPath = $annotationsDir.DIRECTORY_SEPARATOR."annotations.js"; if (file_exists($oldStyleAnnotationsPath)) { - $text = file_get_contents($oldStyleAnnotationsPath); + $text = trim(file_get_contents($oldStyleAnnotationsPath)); $text = str_replace("var comments = ","",$text); if ($text[strlen($text)-1] == ";") { $text = rtrim($text,";"); From 144d6da9bb52eb4f7b0a45355d9c8d48fc37aa0b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 21 Jun 2016 10:43:11 -0400 Subject: [PATCH 330/436] adding event that can be watched for --- src/PatternLab/Watcher.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index e304bec9..18b353c0 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -21,6 +21,7 @@ use \PatternLab\Config; use \PatternLab\Console; use \PatternLab\Data; +use \PatternLab\Dispatcher; use \PatternLab\FileUtil; use \PatternLab\PatternData; use \PatternLab\Util; @@ -61,6 +62,12 @@ public function watch($options = array()) { // make sure a copy of the given options are saved for using when running generate $this->options = $options; + // set-up the Dispatcher + $dispatcherInstance = Dispatcher::getInstance(); + $dispatcherInstance->dispatch("watcher.start"); + popen("php /Users/dmolsen/Sites/patternlab-project/dev/development-edition/vendor/pattern-lab/plugin-reload/src/PatternLab/Reload/AutoReloadServer.php", "r"); + print "hello world"; + // automatically start the auto-refresh tool // DEPRECATED /*if ($reload) { From ed79d41437fc916a46cf75be6161e7c8d5e72bbd Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 21 Jun 2016 10:43:43 -0400 Subject: [PATCH 331/436] adding --suggestions flag to starterkit command --- .../Console/Commands/StarterKitCommand.php | 87 +++++++++++++++++-- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/src/PatternLab/Console/Commands/StarterKitCommand.php b/src/PatternLab/Console/Commands/StarterKitCommand.php index a14f763b..6a491b3e 100644 --- a/src/PatternLab/Console/Commands/StarterKitCommand.php +++ b/src/PatternLab/Console/Commands/StarterKitCommand.php @@ -14,6 +14,8 @@ use \PatternLab\Console; use \PatternLab\Console\Command; use \PatternLab\Fetch; +use \PatternLab\InstallerUtil; +use \PatternLab\JSON; use \PatternLab\Timer; class StarterKitCommand extends Command { @@ -27,32 +29,103 @@ public function __construct() { Console::setCommand($this->command,"Initialize or fetch a specific StarterKit","The StarterKit command downloads StarterKits.","k"); Console::setCommandOption($this->command,"init","Initialize with a blank StarterKit based on the active PatternEngine.","To initialize your project with a base StarterKit:","i"); Console::setCommandOption($this->command,"install:","Fetch a specific StarterKit from GitHub.","To fetch a StarterKit from GitHub:","j:",""); + Console::setCommandOption($this->command,"suggestions","Show suggested StarterKits for this Edition. Offer install prompt.","To show suggested StarterKits for this Edition:"); } public function run() { // find the value given to the command - $init = Console::findCommandOption("i|init"); - $starterkit = Console::findCommandOptionValue("f|install"); + $init = Console::findCommandOption("i|init"); + $starterkit = Console::findCommandOptionValue("f|install"); + $suggestions = Console::findCommandOption("suggestions"); + if ($suggestions) { + + $this->starterKitSuggestions(); + + } else if ($init || $starterkit) { + + $this->starterKitInstall($starterkit, $init); + + } else { + + Console::writeHelpCommand($this->command); + + } + + } + + protected function starterKitInstall($starterkit, $init) { + + // set-up the base starterkit if ($init) { $patternEngine = Config::getOption("patternExtension"); $starterkit = "pattern-lab/starterkit-".$patternEngine."-base"; } - if ($starterkit) { + // download the starterkit + $f = new Fetch(); + $f->fetchStarterKit($starterkit); + + } + + protected function starterKitSuggestions() { + + Console::writeLine(""); + + $composerPath = Config::getOption("baseDir")."/composer.json"; + if (file_exists($composerPath)) { + + $json = file_get_contents($composerPath); + $data = json_decode($json,true); + if ($jsonErrorMessage = JSON::hasError()) { + JSON::lastErrorMsg(Console::getHumanReadablePath($oldStyleAnnotationsPath),$jsonErrorMessage,$data); + } - // download the starterkit - $f = new Fetch(); - $f->fetchStarterKit($starterkit); + if (isset($data["extra"]) && isset($data["extra"]["patternlab"]) && isset($data["extra"]["patternlab"]["starterKitSuggestions"])) { + + $starterKitSuggestions = $data["extra"]["patternlab"]["starterKitSuggestions"]; + + Console::writeInfo("suggested starterkits that work with this edition:", false, true); + foreach ($starterKitSuggestions as $i => $suggestion) { + $num = $i + 1; + Console::writeLine($num.": ".$suggestion, true); + } + + // hack around installer util feature in Console::promptInput + InstallerUtil::$isInteractive = true; + + // prompt for input on the suggestions + Console::writeLine(""); + + $prompt = "choose an option or hit return to cancel:"; + $options = "(ex. 1)"; + $input = Console::promptInput($prompt,$options,"1"); + $result = (int)$input - 1; + + if (isset($starterKitSuggestions[$result])) { + + Console::writeLine(""); + $f = new Fetch(); + $result = $f->fetchStarterKit($starterKitSuggestions[$result]); + + } + + } else { + + Console::writeWarning("this edition has no starterkits to suggested...", false, true); + + } } else { - Console::writeHelpCommand($this->command); + Console::writeError("can't find composer.json to get suggestions...", false, true); } + + } } From 15bbae0682254e71f69bf9179b4664b0223c385b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 21 Jun 2016 13:42:08 -0400 Subject: [PATCH 332/436] removing error message output that i missed --- src/PatternLab/Watcher.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 18b353c0..3f76d2f8 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -65,8 +65,6 @@ public function watch($options = array()) { // set-up the Dispatcher $dispatcherInstance = Dispatcher::getInstance(); $dispatcherInstance->dispatch("watcher.start"); - popen("php /Users/dmolsen/Sites/patternlab-project/dev/development-edition/vendor/pattern-lab/plugin-reload/src/PatternLab/Reload/AutoReloadServer.php", "r"); - print "hello world"; // automatically start the auto-refresh tool // DEPRECATED From 5f9344706c243c990178af26cf9795376e410e9d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 21 Jun 2016 14:00:09 -0400 Subject: [PATCH 333/436] removing unused code --- src/PatternLab/Watcher.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 3f76d2f8..02ece980 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -66,14 +66,6 @@ public function watch($options = array()) { $dispatcherInstance = Dispatcher::getInstance(); $dispatcherInstance->dispatch("watcher.start"); - // automatically start the auto-refresh tool - // DEPRECATED - /*if ($reload) { - $path = str_replace("lib".DIRECTORY_SEPARATOR."PatternLab","autoReloadServer.php",__DIR__); - $fp = popen("php ".$path." -s", "r"); - Console::writeLine("starting page auto-reload..."); - }*/ - if ($noCacheBuster) { Config::setOption("cacheBuster",0); } From 592b3ffc184611f217cac02ef53be1612c790a5e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 27 Jun 2016 11:16:14 -0400 Subject: [PATCH 334/436] fixing minor bug where pseudo pattern wasn't populating a path correctly --- src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php index 58fd5619..a36ad8fc 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php @@ -41,7 +41,7 @@ public function run() { $patternPathDests[$typeDash] = array(); } - $patternPathDests[$typeDash][$nameDash] = $patternStoreData["pathName"]; + $patternPathDests[$typeDash][$nameDash] = (isset($patternStoreData["pseudo"])) ? $patternStoreData["pathOrig"] : $patternStoreData["pathName"];; } From 09151d76c3159d8b453fd4d8d2dc0e01a477cf3d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 27 Jun 2016 13:07:15 -0400 Subject: [PATCH 335/436] checks against a file extension now have to be exact matches --- src/PatternLab/PatternData/Rule.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/PatternData/Rule.php b/src/PatternLab/PatternData/Rule.php index 54d9fb9d..a7c3ab25 100644 --- a/src/PatternLab/PatternData/Rule.php +++ b/src/PatternLab/PatternData/Rule.php @@ -43,7 +43,7 @@ public function test($depth, $ext, $isDir, $isFile, $name) { return false; } - if (($this->compareProp($ext,$this->extProp)) && ($isDir == $this->isDirProp) && ($isFile == $this->isFileProp)) { + if (($this->compareProp($ext,$this->extProp, true)) && ($isDir == $this->isDirProp) && ($isFile == $this->isFileProp)) { $result = true; if ($this->searchProp != "") { $result = $this->compareProp($name,$this->searchProp); @@ -66,7 +66,7 @@ public function test($depth, $ext, $isDir, $isFile, $name) { * * @return {Boolean} whether the compare was successful or not */ - protected function compareProp($name,$propCompare) { + protected function compareProp($name, $propCompare, $exact = false) { if (($name == "") && ($propCompare == "")) { $result = true; @@ -76,18 +76,18 @@ protected function compareProp($name,$propCompare) { $result = true; $props = explode("&&",$propCompare); foreach ($props as $prop) { - $pos = (strpos($name,$prop) !== false) ? true : false; + $pos = $this->testProp($name, $prop, $exact); $result = ($result && $pos); } } else if (strpos($propCompare,"||") !== false) { $result = false; $props = explode("||",$propCompare); foreach ($props as $prop) { - $pos = (strpos($name,$prop) !== false) ? true : false; + $pos = $this->testProp($name, $prop, $exact); $result = ($result || $pos); } } else { - $result = (strpos($name,$propCompare) !== false) ? true : false; + $result = $this->testProp($name, $propCompare, $exact); } return $result; @@ -137,6 +137,23 @@ public function setProp($propName, $propValue) { } + /** + * Test the given property + * @param {String} the value of the property to be tested + * @param {String} the value of the property to be tested against + * @param {Boolean} if this should be an exact match or just a string appearing in another + * + * @return {Boolean} the test result + */ + protected function testProp($propToTest, $propToTestAgainst, $beExact) { + if ($beExact) { + $result = ($propToTest === $propToTestAgainst); + } else { + $result = (strpos($propToTest,$propToTestAgainst) !== false) ? true : false; + } + return $result; + } + /** * Update a property on a given rule * @param {String} the name of the property From 392689c12631e567b12bc4db4a008d9dcbc778ad Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 27 Jun 2016 13:38:44 -0400 Subject: [PATCH 336/436] using pattern data rules to build file extension list that needs watching --- src/PatternLab/Watcher.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 02ece980..eb95edad 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -86,6 +86,25 @@ public function watch($options = array()) { $ignoreDirs = Config::getOption("id"); $patternExt = Config::getOption("patternExtension"); + // build the file extensions based on the rules + $fileExtensions = array(); + $patternRules = PatternData::getRules(); + foreach ($patternRules as $patternRule) { + $extensions = $patternRule->getProp("extProp"); + if (strpos($extensions,"&&") !== false) { + $extensions = explode("&&",$extensions); + } else if (strpos($extensions,"||") !== false) { + $extensions = explode("||",$extensions); + } else { + $extensions = array($extensions); + } + foreach ($extensions as $extension) { + if (!in_array($extension, $fileExtensions)) { + $fileExtensions[] = $extension; + } + } + } + // run forever while (true) { @@ -104,7 +123,7 @@ public function watch($options = array()) { $fileName = str_replace($patternSourceDir.DIRECTORY_SEPARATOR,"",$name); $fileNameClean = str_replace(DIRECTORY_SEPARATOR."_",DIRECTORY_SEPARATOR,$fileName); - if ($object->isFile() && (($object->getExtension() == $patternExt) || ($object->getExtension() == "json") || ($object->getExtension() == "md"))) { + if ($object->isFile() && in_array($object->getExtension(), $fileExtensions)) { // make sure this isn't a hidden pattern $patternParts = explode(DIRECTORY_SEPARATOR,$fileName); From 61500b2fc1abf540c5177ee45199b6250128e4da Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 27 Jun 2016 14:54:34 -0400 Subject: [PATCH 337/436] updating all of the dependencies --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 51dee349..fbfaad61 100644 --- a/composer.json +++ b/composer.json @@ -29,14 +29,14 @@ }, "require": { "php": ">=5.4", - "michelf/php-markdown": "~1.5", - "seld/jsonlint": "~1.3", - "symfony/event-dispatcher": "~2.6", - "symfony/filesystem": "~2.6.4", - "symfony/finder": "~2.6", - "symfony/yaml": "~2.6", - "kevinlebrun/colors.php": "~0.4.1", - "alchemy/zippy": "~0.2.1", + "michelf/php-markdown": "^1.6.0", + "seld/jsonlint": "^1.0.0", + "symfony/event-dispatcher": "^3.0.0", + "symfony/filesystem": "^3.0.0", + "symfony/finder": "^3.0.0", + "symfony/yaml": "^3.0.0", + "kevinlebrun/colors.php": "^1.0.0", + "alchemy/zippy": "^0.3.0", "shudrum/array-finder": "^1.0.0" } } From e1097b0a4bac441d160fa1c6ec20add40573c89e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 28 Jun 2016 09:28:28 -0400 Subject: [PATCH 338/436] removing gatherMQs() --- src/PatternLab/Builder.php | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 407d8ce6..cd29c8c0 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -44,38 +44,6 @@ public function __construct() { } - /** - * Finds Media Queries in CSS files in the source/css/ dir - * - * @return {Array} an array of the appropriate MQs - */ - protected function gatherMQs() { - - $mqs = array(); - - // iterate over all of the other files in the source directory - $finder = new Finder(); - $finder->files()->name("*.css")->in(Config::getOption("sourceDir")); - $finder->sortByName(); - - foreach ($finder as $file) { - - $data = file_get_contents($file->getPathname()); - preg_match_all("/@media.*(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches); - foreach ($matches[3] as $match) { - if (!in_array($match,$mqs)) { - $mqs[] = $match; - } - } - - } - - usort($mqs, "strnatcmp"); - - return $mqs; - - } - /** * Generates the annotations js file */ @@ -151,7 +119,6 @@ protected function generateIndex() { } } $ishControls["ishControlsHide"] = $controlsToHide; - $ishControls["mqs"] = $this->gatherMQs(); $output .= "var ishControls = ".json_encode($ishControls).";"; // load and write out the items for the navigation From 50851f4010d500f90363bbca64c223e6013b305c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 28 Jun 2016 09:28:58 -0400 Subject: [PATCH 339/436] reorganizing composer.json and adding symfony/process --- composer.json | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index fbfaad61..b23d8662 100644 --- a/composer.json +++ b/composer.json @@ -29,14 +29,15 @@ }, "require": { "php": ">=5.4", - "michelf/php-markdown": "^1.6.0", - "seld/jsonlint": "^1.0.0", - "symfony/event-dispatcher": "^3.0.0", - "symfony/filesystem": "^3.0.0", - "symfony/finder": "^3.0.0", - "symfony/yaml": "^3.0.0", - "kevinlebrun/colors.php": "^1.0.0", - "alchemy/zippy": "^0.3.0", - "shudrum/array-finder": "^1.0.0" + "alchemy/zippy": "^0.3", + "kevinlebrun/colors.php": "^1.0", + "michelf/php-markdown": "^1.6", + "seld/jsonlint": "^1.0", + "shudrum/array-finder": "^1.0", + "symfony/event-dispatcher": "^3.0", + "symfony/filesystem": "^3.0", + "symfony/finder": "^3.0", + "symfony/process": "^3.1", + "symfony/yaml": "^3.0" } } From 7ed9aa176a9a4d20f8ed755ffb5856f29d2b8ebc Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:37:24 -0400 Subject: [PATCH 340/436] making sure documentation-surfaced content overwrites pattern-surfaced content --- src/PatternLab/PatternData/Rules/PatternRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/PatternRule.php b/src/PatternLab/PatternData/Rules/PatternRule.php index cb19c166..84a90bc0 100644 --- a/src/PatternLab/PatternData/Rules/PatternRule.php +++ b/src/PatternLab/PatternData/Rules/PatternRule.php @@ -101,7 +101,7 @@ public function run($depth, $ext, $path, $pathName, $name) { } // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive($patternStoreData, PatternData::getOption($patternStoreKey)) : $patternStoreData; PatternData::setOption($patternStoreKey, $patternStoreData); } From ec3fcca0dbd1960312afe278b65b6b9adfeac819 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:43:58 -0400 Subject: [PATCH 341/436] adding getPathPHP and getPathConsole for plugins to hook into for processes --- src/PatternLab/Console.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index d5b4df0f..e17850c0 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -163,6 +163,42 @@ public static function getCommand() { return false; } + /** + * Get the path to PHP binary + * + * @return {String} the path to the PHP executable + */ + public static function getPathPHP() { + + $path = isset($_SERVER["_"]) ? $_SERVER["_"] : Config::getOption("phpBin"); + + if (!$path) { + $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); + Console::writeError("please add the option `phpBin` with the path to PHP to ".$configPath." to run this process..."); + } + + return $path; + + } + + /** + * Get the path to the calling script. Should be core/console but let's not make that assumption + * + * @return {String} the path to the calling script + */ + public static function getPathConsole() { + + $console = isset($_SERVER["SCRIPT_NAME"]) ? $_SERVER["SCRIPT_NAME"] : Config::getOption("phpScriptName"); + + if (!$console) { + $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); + Console::writeError("please add the option `phpScriptName` with the path to your console option (e.g. core/console) to ".$configPath." to run this process..."); + } + + return Config::getOption("baseDir").$console; + + } + /** * Load all of the rules related to Pattern Data */ From f451a6a63afada52e2bee7cce35e98b328f02955 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:44:56 -0400 Subject: [PATCH 342/436] adding a centralized process spawner so processes started by PL can be easily cleaned up --- src/PatternLab/Console/ProcessSpawner.php | 113 ++++++++++++++++++ .../Console/ProcessSpawnerEvent.php | 35 ++++++ 2 files changed, 148 insertions(+) create mode 100644 src/PatternLab/Console/ProcessSpawner.php create mode 100644 src/PatternLab/Console/ProcessSpawnerEvent.php diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php new file mode 100644 index 00000000..18fd7467 --- /dev/null +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -0,0 +1,113 @@ +dispatch('processSpawner.getPluginProcesses',$event); + $this->pluginProcesses = $event->getPluginProcesses(); + + } + + /** + * Spawn the passed commands and those collected from plugins + * @param {Array} a list of commands to spawn + * @param {Boolean} if this should be run in quiet mode + */ + public function spawn($commands = array(), $quiet = false) { + + // set-up a default + $processes = array(); + + // add the default processes sent to the spawner + if (!empty($commands)) { + foreach ($commands as $command) { + $processes[] = $this->buildProcess($command); + } + } + + // add the processes sent to the spawner from plugins + foreach ($this->pluginProcesses as $pluginProcess) { + $processes[] = $this->buildProcess($pluginProcess); + } + + // start the processes + foreach ($processes as $process) { + $process["process"]->start(); + } + + // now monitor and output as appropriate + while (true) { + foreach ($processes as $process) { + if ($process["process"]->isRunning()) { + if (!$quiet && $process["output"]) { + print $process["process"]->getIncrementalOutput(); + } + } + } + usleep(100000); + } + + } + + protected function buildProcess($commandOptions) { + + if (is_string($commandOptions)) { + + $process = new Process(escapeshellcmd((string) $commandOptions)); + return array("process" => $process, "output" => true); + + } else if (is_array($commandOptions)) { + + $commandline = escapeshellcmd((string) $commandOptions["command"]); + $cwd = isset($commandOptions["cwd"]) ? $commandOptions["cwd"] : null; + $env = isset($commandOptions["env"]) ? $commandOptions["env"] : null; + $input = isset($commandOptions["input"]) ? $commandOptions["input"] : null; + $timeout = isset($commandOptions["timeout"]) ? $commandOptions["timeout"] : 60; + $options = isset($commandOptions["options"]) ? $commandOptions["options"] : array(); + $idle = isset($commandOptions["idle"]) ? $commandOptions["idle"] : null; + $output = isset($commandOptions["output"]) ? $commandOptions["output"] : true; + + $process = new Process($commandline, $cwd, $env, $input, $timeout, $options); + + // double-check idle + if (!empty($idle)) { + $process->setIdleTimeout($idle); + } + + return array("process" => $process, "output" => $output); + + } + + } + +} diff --git a/src/PatternLab/Console/ProcessSpawnerEvent.php b/src/PatternLab/Console/ProcessSpawnerEvent.php new file mode 100644 index 00000000..5cc62f12 --- /dev/null +++ b/src/PatternLab/Console/ProcessSpawnerEvent.php @@ -0,0 +1,35 @@ +pluginProcesses = array(); + } + + public function addPluginProcesses($processes = array()) { + if (!empty($processes)) { + $this->pluginProcesses = array_merge($this->pluginProcesses, $processes); + } + } + + public function getPluginProcesses() { + return $this->pluginProcesses; + } + +} From 3d236442e4cc4e2d988c6bd8f5ca577859015aac Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:45:56 -0400 Subject: [PATCH 343/436] populated pathPHP pathConsole when command class is invoked --- src/PatternLab/Console/Command.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Command.php b/src/PatternLab/Console/Command.php index bbb2b20e..6d08af36 100644 --- a/src/PatternLab/Console/Command.php +++ b/src/PatternLab/Console/Command.php @@ -10,16 +10,22 @@ namespace PatternLab\Console; +use \PatternLab\Config; +use \PatternLab\Console; use \PatternLab\Timer; class Command { + protected $pathPHP; + protected $pathConsole; + /** * Set-up a default var */ public function __construct() { - // nothing here yet + $this->pathPHP = Console::getPathPHP(); + $this->pathConsole = Console::getPathConsole(); } From 944efca78ddb6f621c41ae84e58e70f86ed86318 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:47:25 -0400 Subject: [PATCH 344/436] new way to build commands. add support for --with-watch. use processSpawner --- .../Console/Commands/ServerCommand.php | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index b39a2559..87cbefa2 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -13,8 +13,11 @@ use \PatternLab\Config; use \PatternLab\Console; use \PatternLab\Console\Command; +use \PatternLab\Console\Commands\WatchCommand; +use \PatternLab\Console\ProcessSpawner; use \PatternLab\Timer; + class ServerCommand extends Command { public function __construct() { @@ -27,6 +30,7 @@ public function __construct() { Console::setCommandOption($this->command,"host:","Provide a custom hostname. Default value is localhost.","To use a custom hostname and the default port:","",""); Console::setCommandOption($this->command,"port:","Provide a custom port. Default value is 8080.","To use a custom port and the default hostname:","",""); Console::setCommandOption($this->command,"quiet","Turn on quiet mode for the server.","To turn on quiet mode:"); + Console::setCommandOption($this->command,"with-watch","Start watching ./source when starting the server. Takes the same arguments as --watch.","To turn on with-watch mode:"); Console::setCommandSample($this->command,"To provide both a custom hostname and port:","--host --port "); } @@ -43,29 +47,50 @@ public function run() { $publicDir = Config::getOption("publicDir"); $coreDir = Config::getOption("coreDir"); - $host = Console::findCommandOptionValue("host"); - $host = $host ? $host : "localhost"; + $host = Console::findCommandOptionValue("host"); + $host = $host ? $host : "localhost"; - $port = Console::findCommandOptionValue("port"); - $host = $port ? $host.":".$port : $host.":8080"; + $port = Console::findCommandOptionValue("port"); + $host = $port ? $host.":".$port : $host.":8080"; - $null = Console::findCommandOption("quiet"); - $null = $null ? " >& /dev/null" : ""; + $quiet = Console::findCommandOption("quiet"); - $php = isset($_SERVER["_"]) ? $_SERVER["_"] : Config::getOption("phpBin"); + // set-up the base command + $command = $this->pathPHP." -S ".$host." ".$coreDir."/server/router.php"; + $commands = array(); + $commands[] = array("command" => $command, "cwd" => $publicDir, "timeout" => null, "idle" => 600); - if (!$php) { - $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); - Console::writeError("please add the option `phpBin` with the path to PHP to ".$configPath." before running the server..."); + // get the watch command info + if (Console::findCommandOption("with-watch")) { + $watchCommand = new WatchCommand; + $commands[] = array("command" => $watchCommand->build()." --noprocs", "timeout" => null, "idle" => 600); } - // start-up the server with the router Console::writeInfo("server started on http://".$host." - use ctrl+c to exit..."); - passthru("cd ".$publicDir." && ".$php." -S ".$host." ".$coreDir."/server/router.php".$null); + $processSpawner = new ProcessSpawner; + $processSpawner->spawn($commands, $quiet); } } + public function build() { + + $command = $this->pathPHP." ".$this->pathConsole." --".$this->command; + + $host = Console::findCommandOptionValue("host"); + $port = Console::findCommandOptionValue("port"); + + if ($host) { + $command .= " --host ".$host; + } + if ($port) { + $command .= " --port ".$port; + } + + return $command; + + } + } From 19b76824841c94d0ef1cbf796666389cadfdd43c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:49:56 -0400 Subject: [PATCH 345/436] added build() so other functions could call watch. added --noprocs so no processes can be spawned. --- .../Console/Commands/WatchCommand.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index 0d5eb192..ee55adae 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -13,6 +13,7 @@ use \PatternLab\Config; use \PatternLab\Console; use \PatternLab\Console\Command; +use \PatternLab\Console\ProcessSpawner; use \PatternLab\Generator; use \PatternLab\Timer; use \PatternLab\Watcher; @@ -29,6 +30,7 @@ public function __construct() { Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To watch and turn off the cache buster:","n"); Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to source/. The --sk flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:"); + Console::setCommandOption($this->command,"noprocs","Disable plug-in related processes. For use with --server --with-watch.","To disable plug-in related processes:"); Console::setCommandSample($this->command,"To watch only patterns and turn off the cache buster:","--patternsonly --nocache"); //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); @@ -53,6 +55,12 @@ public function run() { } else { + // collect any processes that might be related to watch (e.g. reload). spawn them. + if (!Console::findCommandOption("noprocs")) { + $process = new ProcessSpawner; + $process->run(); + } + // load the generator $g = new Generator(); $g->generate($options); @@ -63,6 +71,20 @@ public function run() { } + } + + public function build() { + + $command = $this->pathPHP." ".$this->pathConsole." --".$this->command; + + if (Console::findCommandOption("p|patternsonly")) { + $command .= " --patternsonly"; + } + if (Console::findCommandOption("n|nocache")) { + $command .= " --nocache"; + } + + return $command; } From 80703d4213c98f557637c08c77c03696a30109a0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:53:34 -0400 Subject: [PATCH 346/436] renaming --noprocs to --no-procs --- src/PatternLab/Console/Commands/ServerCommand.php | 2 +- src/PatternLab/Console/Commands/WatchCommand.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index 87cbefa2..12c5a983 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -63,7 +63,7 @@ public function run() { // get the watch command info if (Console::findCommandOption("with-watch")) { $watchCommand = new WatchCommand; - $commands[] = array("command" => $watchCommand->build()." --noprocs", "timeout" => null, "idle" => 600); + $commands[] = array("command" => $watchCommand->build()." --no-procs", "timeout" => null, "idle" => 600); } Console::writeInfo("server started on http://".$host." - use ctrl+c to exit..."); diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index ee55adae..5f4f48b9 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -30,7 +30,7 @@ public function __construct() { Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean public/.","To watch and generate only the patterns:","p"); Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To watch and turn off the cache buster:","n"); Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to source/. The --sk flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:"); - Console::setCommandOption($this->command,"noprocs","Disable plug-in related processes. For use with --server --with-watch.","To disable plug-in related processes:"); + Console::setCommandOption($this->command,"no-procs","Disable plug-in related processes. For use with --server --with-watch.","To disable plug-in related processes:"); Console::setCommandSample($this->command,"To watch only patterns and turn off the cache buster:","--patternsonly --nocache"); //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); @@ -56,7 +56,7 @@ public function run() { } else { // collect any processes that might be related to watch (e.g. reload). spawn them. - if (!Console::findCommandOption("noprocs")) { + if (!Console::findCommandOption("no-procs")) { $process = new ProcessSpawner; $process->run(); } From 63a377da9610ae44f2180bb27be4d25b9e654888 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 14:54:11 -0400 Subject: [PATCH 347/436] removing unused reload code --- src/PatternLab/Console/Commands/WatchCommand.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index 5f4f48b9..f44fa63e 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -32,7 +32,6 @@ public function __construct() { Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to source/. The --sk flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:"); Console::setCommandOption($this->command,"no-procs","Disable plug-in related processes. For use with --server --with-watch.","To disable plug-in related processes:"); Console::setCommandSample($this->command,"To watch only patterns and turn off the cache buster:","--patternsonly --nocache"); - //Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r"); } @@ -43,9 +42,6 @@ public function run() { $options["moveStatic"] = (Console::findCommandOption("p|patternsonly")) ? false : true; $options["noCacheBuster"] = Console::findCommandOption("n|nocache"); - // DEPRECATED - // $options["autoReload"] = Console::findCommandOption("r|autoreload"); - // see if the starterKit flag was passed so you know what dir to watch if (Console::findCommandOption("sk")) { From 5402fdb6100a7e0bcdbdb12f7ca35d79b374ba0d Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 15:11:54 -0400 Subject: [PATCH 348/436] adding documentation for a function --- src/PatternLab/Console/ProcessSpawner.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php index 18fd7467..5ec8969a 100644 --- a/src/PatternLab/Console/ProcessSpawner.php +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -79,6 +79,10 @@ public function spawn($commands = array(), $quiet = false) { } + /** + * Build the process from the given commandOptions + * @param {Array} the options from which to build the process + */ protected function buildProcess($commandOptions) { if (is_string($commandOptions)) { From eef25f75301f9ccdd88bb2a9618db97442e51029 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 29 Jun 2016 20:13:43 -0400 Subject: [PATCH 349/436] updating badge links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e341c723..e49258e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -![license](https://img.shields.io/github/license/pattern-lab/patternlab-php-core.svg?maxAge=2592000) -[![Packagist](https://img.shields.io/packagist/v/pattern-lab/core.svg?maxAge=2592000)](https://packagist.org/packages/pattern-lab/core) [![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg?maxAge=2592000)](https://gitter.im/pattern-lab/php) +![license](https://img.shields.io/github/license/pattern-lab/patternlab-php-core.svg) +[![Packagist](https://img.shields.io/packagist/v/pattern-lab/core.svg)](https://packagist.org/packages/pattern-lab/core) [![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg)](https://gitter.im/pattern-lab/php) # Pattern Lab Core From b26edc7d57b2b7e16b9225ade2ab8bd695e030bb Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 10:29:03 -0400 Subject: [PATCH 350/436] properly comparing new/old config arrays --- src/PatternLab/Config.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 64aba3b0..c118852d 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -326,14 +326,17 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal // standardize the values for comparison $currentOption = self::getOption($optionName); - $currentOptionValue = is_array($currentOption) ? implode(", ",$currentOption) : $currentOption; - $newOptionValue = is_array($optionValue) ? implode(", ",$optionValue) : $optionValue; + $currentOptionValue = $currentOption; + $newOptionValue = $optionValue; if ($currentOptionValue != $newOptionValue) { // prompt for input - $prompt = "update the config option ".$optionName." (".$currentOptionValue.") with the value ".$newOptionValue."?"; - $options = "Y/n"; + if (is_array($currentOptionValue)) { + $prompt = "update the config option ".$optionName." with the value from the package install?"; + } else { + $prompt = "update the config option ".$optionName." (".$currentOptionValue.") with the value ".$newOptionValue."?"; + }$options = "Y/n"; $input = Console::promptInput($prompt,$options,"Y"); if ($input == "y") { From 2c6a36fc7ac9616a4186623bd85edc7d0f601f61 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 10:54:20 -0400 Subject: [PATCH 351/436] adding 'plugins' as an exposed option --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index c118852d..a54ee14b 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -241,6 +241,7 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); self::setExposedOption("patternExtension"); + self::setExposedOption("plugins"); } From e8a84b4a37b111d7e86dffa25c250b975ad8d10c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 11:29:28 -0400 Subject: [PATCH 352/436] updating PS->run() to PS->spawn() --- src/PatternLab/Console/Commands/WatchCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index f44fa63e..e50779cd 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -54,7 +54,7 @@ public function run() { // collect any processes that might be related to watch (e.g. reload). spawn them. if (!Console::findCommandOption("no-procs")) { $process = new ProcessSpawner; - $process->run(); + $process->spawn(); } // load the generator From a5a991f348deada3cf740611fc690dd32996a737 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 11:35:02 -0400 Subject: [PATCH 353/436] check that their are processes to start --- src/PatternLab/Console/ProcessSpawner.php | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php index 5ec8969a..ad41211b 100644 --- a/src/PatternLab/Console/ProcessSpawner.php +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -60,21 +60,25 @@ public function spawn($commands = array(), $quiet = false) { $processes[] = $this->buildProcess($pluginProcess); } - // start the processes - foreach ($processes as $process) { - $process["process"]->start(); - } - - // now monitor and output as appropriate - while (true) { + // if there are processes to spawn do so + if (!empty($processes)) { + + // start the processes foreach ($processes as $process) { - if ($process["process"]->isRunning()) { - if (!$quiet && $process["output"]) { - print $process["process"]->getIncrementalOutput(); + $process["process"]->start(); + } + + // check on them and produce output + while (true) { + foreach ($processes as $process) { + if ($process["process"]->isRunning()) { + if (!$quiet && $process["output"]) { + print $process["process"]->getIncrementalOutput(); + } } } + usleep(100000); } - usleep(100000); } } From c927a564b7679025742096f191ed311c7885e198 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 16:20:00 -0400 Subject: [PATCH 354/436] forcing watch to start a sub process --- .../Console/Commands/WatchCommand.php | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/Console/Commands/WatchCommand.php b/src/PatternLab/Console/Commands/WatchCommand.php index e50779cd..ae772b04 100644 --- a/src/PatternLab/Console/Commands/WatchCommand.php +++ b/src/PatternLab/Console/Commands/WatchCommand.php @@ -51,20 +51,32 @@ public function run() { } else { - // collect any processes that might be related to watch (e.g. reload). spawn them. - if (!Console::findCommandOption("no-procs")) { + if (Console::findCommandOption("no-procs")) { + + // don't have to worry about loading processes so launch watcher + + // load the generator + $g = new Generator(); + $g->generate($options); + + // load the watcher + $w = new Watcher(); + $w->watch($options); + + } else { + + // a vanilla --watch command needs to have a --no-procs version built + // so we don't get caught in while() loops. re-request the console command + $commands = array(); + $commands[] = array("command" => $this->build()." --no-procs", "timeout" => null, "idle" => 600); + + Console::writeInfo("spawning the watch process..."); + $process = new ProcessSpawner; - $process->spawn(); + $process->spawn($commands); + } - // load the generator - $g = new Generator(); - $g->generate($options); - - // load the watcher - $w = new Watcher(); - $w->watch($options); - } } From be82b4ff7e0943d6fd829e14fefae6b4f3afcb89 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 16:27:25 -0400 Subject: [PATCH 355/436] testing a version number bump --- config/config.yml.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml.default b/config/config.yml.default index 5751dee2..9dfecd30 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -1,7 +1,7 @@ ## Configuration Options for Pattern Lab # pattern lab version -v: "2.2.1" +v: "2.5.0" # what to do when included config var conflicts, q for question, a for always override, n for never override overrideConfig: "q" From fbb04c50e8e231adbd2c6676f664ba6b6e8954c1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 16:34:21 -0400 Subject: [PATCH 356/436] removing unused reload blocks --- src/PatternLab/Watcher.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index eb95edad..f8f3c94e 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -279,24 +279,11 @@ public function watch($options = array()) { // taking out the garbage. basically killing mustache after each run. if (gc_enabled()) gc_collect_cycles(); - // output anything the reload server might send our way - // DEPRECATED - /* - if ($reload) { - $output = fgets($fp, 100); - if ($output != "\n") print $output; - } - */ - // pause for .05 seconds to give the CPU a rest usleep(50000); } - // close the auto-reload process, this shouldn't do anything - // DEPRECATED - // fclose($fp); - } /** From 9eaae78405a9f54682dd0c2037425416593f5976 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 30 Jun 2016 16:55:27 -0400 Subject: [PATCH 357/436] moving the sayings into their own class --- .../Console/Commands/GenerateCommand.php | 5 +- src/PatternLab/Generator.php | 63 ----------- src/PatternLab/Saying.php | 107 ++++++++++++++++++ 3 files changed, 111 insertions(+), 64 deletions(-) create mode 100644 src/PatternLab/Saying.php diff --git a/src/PatternLab/Console/Commands/GenerateCommand.php b/src/PatternLab/Console/Commands/GenerateCommand.php index b3c03ebc..286567b4 100644 --- a/src/PatternLab/Console/Commands/GenerateCommand.php +++ b/src/PatternLab/Console/Commands/GenerateCommand.php @@ -14,6 +14,7 @@ use \PatternLab\Console; use \PatternLab\Console\Command; use \PatternLab\Generator; +use \PatternLab\Saying; use \PatternLab\Timer; class GenerateCommand extends Command { @@ -39,7 +40,9 @@ public function run() { $g = new Generator(); $g->generate($options); - $g->printSaying(); + + $s = new Saying(); + $s->say(); } diff --git a/src/PatternLab/Generator.php b/src/PatternLab/Generator.php index 2b1d3b54..d6c936cf 100644 --- a/src/PatternLab/Generator.php +++ b/src/PatternLab/Generator.php @@ -158,67 +158,4 @@ protected function moveStatic() { } - /** - * Randomly prints a saying after the generate is complete - */ - public function printSaying() { - - $randomNumber = rand(0,3); - $colors = array("ok","options","info","warning","error"); - $color = (isset($colors[$randomNumber])) ? $colors[$randomNumber] : "desc"; - - $randomNumber = rand(0,60); - $sayings = array( - "have fun storming the castle", - "be well, do good work, and keep in touch", - "may the sun shine, all day long", - "smile :)", - "namaste", - "walk as if you are kissing the earth with your feet", - "to be beautiful means to be yourself", - "i was thinking of the immortal words of socrates, who said '...i drank what?'", - "let me take this moment to compliment you on your fashion sense, particularly your slippers", - "42", - "he who controls the spice controls the universe", - "the greatest thing you'll ever learn is just to love and be loved in return", - "nice wand", - "i don't have time for a grudge match with every poseur in a parka", - "han shot first", - "what we've got here is a failure to communicate", - "mama always said life was like a box of chocolates. you never know what you're gonna get", - "soylent green is people", - "a little word of advice, my friend. sometimes you gotta let those hard-to-reach chips go", - "you don't understand! i coulda had class. i coulda been a contender. i could've been somebody, instead of a bum, which is what i am", - "shop smart. shop s-mart", - "i see dead people", - "well, nobody's perfect", - "it's alive! it's alive!", - "you've got to ask yourself one question: 'do I feel lucky?' well, do ya, punk?", - "badges? we ain't got no badges! we don't need no badges! i don't have to show you any stinking badges!", - "the holy roman empire was neither holy nor roman. discuss.", - "well, here's another nice mess you've gotten me into!", - "here's johnny!", - "hello, gorgeous", - "nobody puts baby in a corner", - "life moves pretty fast. if you don't stop and look around once in a while, you could miss it", - "my precious", - "be yourself; everyone else is already taken", - "the ships hung in the sky in much the same way that bricks don't", - "klaatu barada nikto", - "i am putting myself to the fullest possible use, which is all i think that any conscious entity can ever hope to do", - "just what do you think you're doing, dave?", - "do what i do. hold tight and pretend it's a plan!", - "(╯°□°)╯︵ ┻━┻", - "¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>", - "@}~}~~~", - "(>'.')> (>'.')> (>'.')> ", - "\(^-^)/", - "you've been at this awhile; perhaps it's time for a walk outside?" - ); - if (isset($sayings[$randomNumber])) { - Console::writeLine("<".$color.">".$sayings[$randomNumber]."..."); - } - - } - } diff --git a/src/PatternLab/Saying.php b/src/PatternLab/Saying.php new file mode 100644 index 00000000..274037b2 --- /dev/null +++ b/src/PatternLab/Saying.php @@ -0,0 +1,107 @@ +<(((º>", + "@}~}~~~", + "(>'.')> (>'.')> (>'.')> ", + "\(^-^)/", + "you've been at this awhile; perhaps it's time for a walk outside?" + ); + + // grab user sayings + $userSayings = Config::getOption("sayings"); + if (is_array($userSayings)) { + $sayings = array_merge($sayings, $userSayings); + } + + // i just didn't want to indent the crap above + $this->sayings = $sayings; + + print_r($sayings); + + } + + /** + * Randomly prints a saying after the generate is complete + */ + public function say() { + + // set a color + $colors = array("ok","options","info","warning","error"); + $randomNumber = rand(0,count($colors)-1); + $color = (isset($colors[$randomNumber])) ? $colors[$randomNumber] : "desc"; + + // set a 1 in 3 chance that a saying is printed + $randomNumber = rand(0,(count($this->sayings)-1)*3); + if (isset($this->sayings[$randomNumber])) { + Console::writeLine("<".$color.">".$this->sayings[$randomNumber]."..."); + } + + } + +} From 2961c04c20e5b4747fbe59cd0b177dd18d370520 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Jul 2016 15:36:40 -0400 Subject: [PATCH 358/436] removing a dump of the sayings --- src/PatternLab/Saying.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/PatternLab/Saying.php b/src/PatternLab/Saying.php index 274037b2..46d96071 100644 --- a/src/PatternLab/Saying.php +++ b/src/PatternLab/Saying.php @@ -82,8 +82,6 @@ public function __construct() { // i just didn't want to indent the crap above $this->sayings = $sayings; - print_r($sayings); - } /** From 7440cb524c7ba2d40b629d1780e91ad6b54f3623 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Jul 2016 15:36:53 -0400 Subject: [PATCH 359/436] hardcoding watch starterkit for now --- src/PatternLab/Watcher.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index f8f3c94e..0a5da80c 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -327,20 +327,19 @@ private function updateSite($fileName,$message,$verbose = true) { public function watchStarterKit() { // double-checks options was properly set - $starterKit = Config::getOption("starterKit"); + /*$starterKit = Config::getOption("starterKit"); if (!$starterKit) { Console::writeError("need to have a starterkit set in the config..."); - } + }*/ // set-up the full starterkit path - $starterKitPath = Config::getOption("packagesDir").DIRECTORY_SEPARATOR.$starterKit.DIRECTORY_SEPARATOR."dist"; + $starterKitPath = Config::getOption("baseDir")."vendor/pattern-lab/starterkit-mustache-demo/dist"; if (!is_dir($starterKitPath)) { Console::writeError("the starterkit doesn't seem to exist..."); } // default vars $sourceDir = Config::getOption("sourceDir"); - $packagesDir = Config::getOption("packagesDir"); $fs = new Filesystem(); From 9c058053fd8d4d7b564a29dea10c187ae4ca0ede Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Jul 2016 18:01:03 -0400 Subject: [PATCH 360/436] removing uppercase for section and pattern titles --- .../PatternData/Exporters/PatternPartialsExporter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index b3f1ea37..b3562d9b 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -47,7 +47,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); + $patternPartialData["patternName"] = $patternStoreData["nameClean"]; $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternPartialCode"] = $patternStoreData["code"]; @@ -86,7 +86,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); + $patternPartialData["patternName"] = $patternStoreData["nameClean"]; $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/index.html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternSectionSubtype"] = true; From a88bb5b3b3bfa50971d7e9fb926205b0b1703d54 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Jul 2016 18:16:48 -0400 Subject: [PATCH 361/436] adding an option for a user to say where the starterkit to watch is --- src/PatternLab/Watcher.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/Watcher.php b/src/PatternLab/Watcher.php index 0a5da80c..50a6059f 100644 --- a/src/PatternLab/Watcher.php +++ b/src/PatternLab/Watcher.php @@ -23,6 +23,7 @@ use \PatternLab\Data; use \PatternLab\Dispatcher; use \PatternLab\FileUtil; +use \PatternLab\InstallerUtil; use \PatternLab\PatternData; use \PatternLab\Util; use \PatternLab\Timer; @@ -324,22 +325,28 @@ private function updateSite($fileName,$message,$verbose = true) { } - public function watchStarterKit() { - - // double-checks options was properly set - /*$starterKit = Config::getOption("starterKit"); - if (!$starterKit) { - Console::writeError("need to have a starterkit set in the config..."); - }*/ + protected function starterKitPathPrompt() { + + // need to figure this out long-term + InstallerUtil::$isInteractive = true; + $input = Console::promptInput("Tell me the path to the starterkit you want to watch.","e.g. vendor/pattern-lab/starterkit-mustache-demo/dist","baz",false); // set-up the full starterkit path - $starterKitPath = Config::getOption("baseDir")."vendor/pattern-lab/starterkit-mustache-demo/dist"; + $starterKitPath = Config::getOption("baseDir").$input; if (!is_dir($starterKitPath)) { - Console::writeError("the starterkit doesn't seem to exist..."); + Console::writeWarning("that doesn't seem to be a real directory. let's try again..."); + $starterKitPath = $this->starterKitPathPrompt(); } + return $starterKitPath; + + } + + public function watchStarterKit() { + // default vars - $sourceDir = Config::getOption("sourceDir"); + $starterKitPath = $this->starterKitPathPrompt(); + $sourceDir = Config::getOption("sourceDir"); $fs = new Filesystem(); From 64176a8fcfd55f19f3a8b42c63feba4c8ed765d9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Jul 2016 20:39:39 -0400 Subject: [PATCH 362/436] adding back strtoupper() for 2.5.0 release until brad has those styles locked in --- .../PatternData/Exporters/PatternPartialsExporter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index b3562d9b..b3f1ea37 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -47,7 +47,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = $patternStoreData["nameClean"]; + $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternPartialCode"] = $patternStoreData["code"]; @@ -86,7 +86,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = $patternStoreData["nameClean"]; + $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/index.html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternSectionSubtype"] = true; From 45a3788e4770520e491c08693e11b47ec29e3b24 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 1 Jul 2016 21:28:42 -0400 Subject: [PATCH 363/436] handling merging of plugin data --- src/PatternLab/Config.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index a54ee14b..babcfd0d 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -327,8 +327,8 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal // standardize the values for comparison $currentOption = self::getOption($optionName); - $currentOptionValue = $currentOption; - $newOptionValue = $optionValue; + $currentOptionValue = isset($currentOption["plugins"]) ? $currentOption["plugins"] : $currentOption; + $newOptionValue = isset($optionValue["plugins"]) ? $optionValue["plugins"] : $optionValue; if ($currentOptionValue != $newOptionValue) { @@ -341,8 +341,16 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal $input = Console::promptInput($prompt,$options,"Y"); if ($input == "y") { + + // handle plug-in values + if (isset($optionValue["plugins"])) { + $optionValue = array_replace_recursive($currentOption, $optionValue); + } + + // update the config option self::writeUpdateConfigOption($optionName,$optionValue); Console::writeInfo("config option ".$optionName." updated...", false, true); + } else { Console::writeWarning("config option ".$optionName." not updated...", false, true); } From dc521eff98cbf469547d5267d719b37213c7ba30 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 2 Jul 2016 09:56:18 -0400 Subject: [PATCH 364/436] properly handling install of plugins --- src/PatternLab/Config.php | 47 ++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index babcfd0d..8393e3b2 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -327,32 +327,57 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal // standardize the values for comparison $currentOption = self::getOption($optionName); - $currentOptionValue = isset($currentOption["plugins"]) ? $currentOption["plugins"] : $currentOption; - $newOptionValue = isset($optionValue["plugins"]) ? $optionValue["plugins"] : $optionValue; + $currentOptionValue = $currentOption; + $newOptionValue = $optionValue; + $optionNameOutput = $optionName; + + // dive into plugins to do a proper comparison to + if ($optionName == "plugins") { + + // replace the data in anticipation of it being used + $optionValue = array_replace_recursive($currentOption, $newOptionValue); + + // get the key of the plugin that is being added/updated + reset($newOptionValue); + $newOptionKey = key($newOptionValue); + + if (!array_key_exists($newOptionKey, $currentOptionValue)) { + + // if the key doesn't exist just write out the new config and move on + self::writeUpdateConfigOption($optionName,$optionValue); + return; + + } else { + + // see if the existing configs for the plugin exists. if so just return with no changes + if ($newOptionValue[$newOptionKey] == $currentOptionValue[$newOptionKey]) { + return; + } else { + $optionNameOutput = $optionName.".".$newOptionKey; + } + + } + + } if ($currentOptionValue != $newOptionValue) { // prompt for input if (is_array($currentOptionValue)) { - $prompt = "update the config option ".$optionName." with the value from the package install?"; + $prompt = "update the config option ".$optionNameOutput." with the value from the package install?"; } else { - $prompt = "update the config option ".$optionName." (".$currentOptionValue.") with the value ".$newOptionValue."?"; + $prompt = "update the config option ".$optionNameOutput." (".$currentOptionValue.") with the value ".$newOptionValue."?"; }$options = "Y/n"; $input = Console::promptInput($prompt,$options,"Y"); if ($input == "y") { - // handle plug-in values - if (isset($optionValue["plugins"])) { - $optionValue = array_replace_recursive($currentOption, $optionValue); - } - // update the config option self::writeUpdateConfigOption($optionName,$optionValue); - Console::writeInfo("config option ".$optionName." updated...", false, true); + Console::writeInfo("config option ".$optionNameOutput." updated...", false, true); } else { - Console::writeWarning("config option ".$optionName." not updated...", false, true); + Console::writeWarning("config option ".$optionNameOutput." not updated...", false, true); } } From f5f0ed390fc7c092ab96e97722cdaac4104c6827 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sat, 2 Jul 2016 19:46:20 -0400 Subject: [PATCH 365/436] cleaning up some tabs --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index b23d8662..1deda66d 100644 --- a/composer.json +++ b/composer.json @@ -29,15 +29,15 @@ }, "require": { "php": ">=5.4", - "alchemy/zippy": "^0.3", - "kevinlebrun/colors.php": "^1.0", + "alchemy/zippy": "^0.3", + "kevinlebrun/colors.php": "^1.0", "michelf/php-markdown": "^1.6", "seld/jsonlint": "^1.0", - "shudrum/array-finder": "^1.0", + "shudrum/array-finder": "^1.0", "symfony/event-dispatcher": "^3.0", "symfony/filesystem": "^3.0", "symfony/finder": "^3.0", "symfony/process": "^3.1", - "symfony/yaml": "^3.0" + "symfony/yaml": "^3.0" } } From 41d2c64e3f8141fed7a7b6693c9d9b2e929c9421 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 5 Jul 2016 20:51:25 -0400 Subject: [PATCH 366/436] removing strtoupper() for pattern and subtype name --- .../PatternData/Exporters/PatternPartialsExporter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index b3f1ea37..b3562d9b 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -47,7 +47,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); + $patternPartialData["patternName"] = $patternStoreData["nameClean"]; $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternPartialCode"] = $patternStoreData["code"]; @@ -86,7 +86,7 @@ public function run($type = "", $subtype = "") { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) { $patternPartialData = array(); - $patternPartialData["patternName"] = strtoupper($patternStoreData["nameClean"]); + $patternPartialData["patternName"] = $patternStoreData["nameClean"]; $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/index.html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternSectionSubtype"] = true; From 613c7b6db41610ee858b0a6b80c9e0ffc7aab08f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 6 Jul 2016 22:42:34 -0400 Subject: [PATCH 367/436] making sure pseudo-patterns use array_replace_recursive() just like everywhere else --- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 26a83888..e7f03270 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -168,10 +168,10 @@ public function run($depth, $ext, $path, $pathName, $name) { } // make sure the pattern data is an array before merging the data - $patternStoreData["data"] = is_array($patternData) ? array_merge($patternDataBase, $patternData) : $patternDataBase; + $patternStoreData["data"] = is_array($patternData) ? array_replace_recursive($patternDataBase, $patternData) : $patternDataBase; // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_merge(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive((PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; PatternData::setOption($patternStoreKey, $patternStoreData); } From e0cdee5d4c2eb535e09867e6d9ab1b356c89de27 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 11 Jul 2016 22:35:50 -0400 Subject: [PATCH 368/436] fixing a syntax error --- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index e7f03270..426332e9 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -171,7 +171,7 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternStoreData["data"] = is_array($patternData) ? array_replace_recursive($patternDataBase, $patternData) : $patternDataBase; // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive((PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; PatternData::setOption($patternStoreKey, $patternStoreData); } From 2d2c0d5e529a1e9924585ad66d12097abde8e35b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 11:21:02 -0400 Subject: [PATCH 369/436] addressing if annotations are missing --- src/PatternLab/Annotations.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 465ee551..8378009e 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -55,6 +55,9 @@ public static function gather() { if (!is_dir($annotationsDir)) { Console::writeWarning("".Console::getHumanReadablePath($annotationsDir)." doesn't exist so you won't have annotations..."); mkdir($annotationsDir); + } else { + + } // find the markdown-based annotations @@ -90,6 +93,7 @@ public static function gather() { } // read in the old style annotations.js, modify the data and generate JSON array to merge + $data = array(); $oldStyleAnnotationsPath = $annotationsDir.DIRECTORY_SEPARATOR."annotations.js"; if (file_exists($oldStyleAnnotationsPath)) { $text = trim(file_get_contents($oldStyleAnnotationsPath)); @@ -103,8 +107,10 @@ public static function gather() { } } - // merge in any data from the old file - self::$store["comments"] = array_merge(self::$store["comments"],$data["comments"]); + // merge in any data from the old file if the json decode was successful + if (is_array($data) && isset($data["comments"])) { + self::$store["comments"] = array_merge(self::$store["comments"],$data["comments"]); + } $dispatcherInstance->dispatch("annotations.gatherEnd"); From 63d40e456cf6405397356bfa7264d80ee1d6d594 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 11:33:31 -0400 Subject: [PATCH 370/436] capturing if _patterns is missing --- src/PatternLab/PatternData.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index d19962cb..39129553 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -113,6 +113,9 @@ public static function gather($options = array()) { // iterate over the patterns & related data and regenerate the entire site if they've changed // seems a little silly to use symfony finder here. not really giving me any power + if (!is_dir(Config::getOption("patternSourceDir"))) { + Console::writeError("having patterns is important. please make sure you've installed a starterkit and/or that ".Console::getHumanReadablePath(Config::getOption("patternSourceDir"))." exists..."); + } $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(Config::getOption("patternSourceDir")), \RecursiveIteratorIterator::SELF_FIRST); $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS); From 8685a93041fba57ad2de5050c4f1cfcfc45fe486 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 12:12:30 -0400 Subject: [PATCH 371/436] adding a timeout and better error handling --- src/PatternLab/Console/ProcessSpawner.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php index ad41211b..142f31c4 100644 --- a/src/PatternLab/Console/ProcessSpawner.php +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -63,18 +63,28 @@ public function spawn($commands = array(), $quiet = false) { // if there are processes to spawn do so if (!empty($processes)) { + // get the time out + $timeout = Config::getOption("timeout") ? (int)Config::getOption("timeout") : 30; + // start the processes foreach ($processes as $process) { $process["process"]->start(); + $process["process"]->setTimeout($timeout); } // check on them and produce output while (true) { foreach ($processes as $process) { - if ($process["process"]->isRunning()) { - if (!$quiet && $process["output"]) { - print $process["process"]->getIncrementalOutput(); + try { + if ($process["process"]->isRunning()) { + $process["process"]->checkTimeout(); + if (!$quiet && $process["output"]) { + print $process["process"]->getIncrementalOutput(); + print $process["process"]->getIncrementalErrorOutput(); + } } + } catch (\RuntimeException $e) { + Console::writeError("pattern lab processes automatically time out after ".$timeout." seconds..."); } } usleep(100000); From 820d5b6222516feee48a57f1b1f684edecfa6b30 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 13:34:26 -0400 Subject: [PATCH 372/436] updating the default timeout to 3600 seconds --- src/PatternLab/Console/ProcessSpawner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php index 142f31c4..6baca5ef 100644 --- a/src/PatternLab/Console/ProcessSpawner.php +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -64,7 +64,7 @@ public function spawn($commands = array(), $quiet = false) { if (!empty($processes)) { // get the time out - $timeout = Config::getOption("timeout") ? (int)Config::getOption("timeout") : 30; + $timeout = Config::getOption("timeout") ? (int)Config::getOption("timeout") : 3600; // start the processes foreach ($processes as $process) { From 89cb0ff76308fac108a9cbf9764612d8e38cea31 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 13:39:51 -0400 Subject: [PATCH 373/436] these rules don't depend on something being hidden --- .../PatternData/Rules/DocumentationRule.php | 81 +++++++++---------- .../Rules/PatternInfoListItemsRule.php | 29 +++---- .../PatternData/Rules/PatternInfoRule.php | 61 +++++++------- 3 files changed, 76 insertions(+), 95 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index 9cfbd76e..a5d20b2e 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -47,55 +47,50 @@ public function run($depth, $ext, $path, $pathName, $name) { $docDash = $this->getPatternName(str_replace("_","",$doc),false); // colors $docPartial = $patternTypeDash."-".$docDash; - // if the pattern isn't hidden do stuff - if (!$hidden) { - - // default vars - $patternSourceDir = Config::getOption("patternSourceDir"); - - // parse data - $text = file_get_contents($patternSourceDir.DIRECTORY_SEPARATOR.$pathName); - list($yaml,$markdown) = Documentation::parse($text); - - // grab the title and unset it from the yaml so it doesn't get duped in the meta - if (isset($yaml["title"])) { - $title = $yaml["title"]; - unset($yaml["title"]); - } - - // figure out if this is a pattern subtype - $patternSubtypeDoc = false; - if ($depth == 1) { - // go through all of the directories to see if this one matches our doc - foreach (glob($patternSourceDir.DIRECTORY_SEPARATOR.$patternType.DIRECTORY_SEPARATOR."*",GLOB_ONLYDIR) as $dir) { - $dir = str_replace($patternSourceDir.DIRECTORY_SEPARATOR.$patternType.DIRECTORY_SEPARATOR,"",$dir); - if ($dir == $doc) { - $patternSubtypeDoc = true; - break; - } + // default vars + $patternSourceDir = Config::getOption("patternSourceDir"); + + // parse data + $text = file_get_contents($patternSourceDir.DIRECTORY_SEPARATOR.$pathName); + list($yaml,$markdown) = Documentation::parse($text); + + // grab the title and unset it from the yaml so it doesn't get duped in the meta + if (isset($yaml["title"])) { + $title = $yaml["title"]; + unset($yaml["title"]); + } + + // figure out if this is a pattern subtype + $patternSubtypeDoc = false; + if ($depth == 1) { + // go through all of the directories to see if this one matches our doc + foreach (glob($patternSourceDir.DIRECTORY_SEPARATOR.$patternType.DIRECTORY_SEPARATOR."*",GLOB_ONLYDIR) as $dir) { + $dir = str_replace($patternSourceDir.DIRECTORY_SEPARATOR.$patternType.DIRECTORY_SEPARATOR,"",$dir); + if ($dir == $doc) { + $patternSubtypeDoc = true; + break; } - } - $category = ($patternSubtypeDoc) ? "patternSubtype" : "pattern"; - $patternStoreKey = ($patternSubtypeDoc) ? $docPartial."-plsubtype" : $docPartial; - - $patternStoreData = array("category" => $category, - "desc" => $markdown, - "descExists" => true, - "meta" => $yaml, - "full" => $doc); + } + + $category = ($patternSubtypeDoc) ? "patternSubtype" : "pattern"; + $patternStoreKey = ($patternSubtypeDoc) ? $docPartial."-plsubtype" : $docPartial; + + $patternStoreData = array("category" => $category, + "desc" => $markdown, + "descExists" => true, + "meta" => $yaml, + "full" => $doc); - if (isset($title)) { - $patternStoreData["nameClean"] = $title; - } - - // if the pattern data store already exists make sure this data overwrites it - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; - PatternData::setOption($patternStoreKey, $patternStoreData); - + if (isset($title)) { + $patternStoreData["nameClean"] = $title; } + // if the pattern data store already exists make sure this data overwrites it + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + PatternData::setOption($patternStoreKey, $patternStoreData); + } } diff --git a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php index ecba0b56..9e8fe6fa 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoListItemsRule.php @@ -39,29 +39,22 @@ public function run($depth, $ext, $path, $pathName, $name) { // load default vars $patternTypeDash = PatternData::getPatternTypeDash(); - // should this pattern get rendered? - $hidden = ($name[0] == "_"); - // set-up the names, $name == foo.listitems.json $pattern = str_replace(".listitems.".$ext,"",$name); // foo $patternDash = $this->getPatternName($pattern,false); // foo $patternPartial = $patternTypeDash."-".$patternDash; // atoms-foo - if (!$hidden) { - - $patternStoreData = array("category" => "pattern"); - - $data = Data::getListItems("_patterns/".$pathName,$ext); - $patternStoreData["listItems"] = $data; - - // create a key for the data store - $patternStoreKey = $patternPartial; - - // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; - PatternData::setOption($patternStoreKey, $patternStoreData); - - } + $patternStoreData = array("category" => "pattern"); + + $data = Data::getListItems("_patterns/".$pathName,$ext); + $patternStoreData["listItems"] = $data; + + // create a key for the data store + $patternStoreKey = $patternPartial; + + // if the pattern data store already exists make sure it is merged and overwrites this data + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + PatternData::setOption($patternStoreKey, $patternStoreData); } diff --git a/src/PatternLab/PatternData/Rules/PatternInfoRule.php b/src/PatternLab/PatternData/Rules/PatternInfoRule.php index b18818d9..f8723251 100644 --- a/src/PatternLab/PatternData/Rules/PatternInfoRule.php +++ b/src/PatternLab/PatternData/Rules/PatternInfoRule.php @@ -39,51 +39,44 @@ public function run($depth, $ext, $path, $pathName, $name) { // load default vars $patternTypeDash = PatternData::getPatternTypeDash(); - // should this pattern get rendered? - $hidden = ($name[0] == "_"); - // set-up the names, $name == foo.json $pattern = str_replace(".".$ext,"",$name); // foo $patternDash = $this->getPatternName($pattern,false); // foo $patternPartial = $patternTypeDash."-".$patternDash; // atoms-foo - if (!$hidden) { - - $patternStoreData = array("category" => "pattern"); - - $file = file_get_contents(Config::getOption("patternSourceDir")."/".$pathName); - - if ($ext == "json") { - $data = json_decode($file,true); - if ($jsonErrorMessage = JSON::hasError()) { - JSON::lastErrorMsg($name,$jsonErrorMessage,$data); - } - } else { - - try { - $data = YAML::parse($file); - } catch (ParseException $e) { - printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); - } - - // single line of text won't throw a YAML error. returns as string - if (gettype($data) == "string") { - $data = array(); - } - + $patternStoreData = array("category" => "pattern"); + + $file = file_get_contents(Config::getOption("patternSourceDir")."/".$pathName); + + if ($ext == "json") { + $data = json_decode($file,true); + if ($jsonErrorMessage = JSON::hasError()) { + JSON::lastErrorMsg($name,$jsonErrorMessage,$data); } + } else { - $patternStoreData["data"] = $data; - - // create a key for the data store - $patternStoreKey = $patternPartial; + try { + $data = YAML::parse($file); + } catch (ParseException $e) { + printf("unable to parse ".$pathNameClean.": %s..\n", $e->getMessage()); + } - // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; - PatternData::setOption($patternStoreKey, $patternStoreData); + // single line of text won't throw a YAML error. returns as string + if (gettype($data) == "string") { + $data = array(); + } } + $patternStoreData["data"] = $data; + + // create a key for the data store + $patternStoreKey = $patternPartial; + + // if the pattern data store already exists make sure it is merged and overwrites this data + $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + PatternData::setOption($patternStoreKey, $patternStoreData); + } } From 2698e50c11128a1a3db682969170253a2a2d5ae3 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 13:40:55 -0400 Subject: [PATCH 374/436] render every pattern --- src/PatternLab/PatternData/Helpers/RawPatternHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php index 0c37facc..9c2de8c5 100644 --- a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php +++ b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php @@ -41,7 +41,7 @@ public function run() { // iterate to get raw data loaded into the PatternData Store foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { + if ($patternStoreData["category"] == "pattern") { // figure out the source path for the pattern to render $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; From 7e88506c6697d365e8e5b60aa7405a1c0827f876 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 13:43:20 -0400 Subject: [PATCH 375/436] render every pattern --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 7cd4806a..0dccb141 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -57,7 +57,7 @@ public function run() { // iterate to process each pattern foreach ($store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { + if ($patternStoreData["category"] == "pattern") { $data = Data::getPatternSpecificData($patternStoreKey); From c8fd1934d3a6a2f2621f2b703258b4155854d823 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 13:44:44 -0400 Subject: [PATCH 376/436] removing a variable set that i'm not using --- src/PatternLab/PatternData/Rules/DocumentationRule.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index a5d20b2e..b391e2f6 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -39,9 +39,6 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternTypeDash = PatternData::getPatternTypeDash(); $dirSep = PatternData::getDirSep(); - // make sure the pattern isn't hidden - $hidden = ($name[0] == "_"); - // set-up the names, $name == 00-colors.md $doc = str_replace(".".$this->extProp,"",$name); // 00-colors $docDash = $this->getPatternName(str_replace("_","",$doc),false); // colors From c1594630399bbc2f5b3a3a72d7c87286ea1336f9 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 13:49:42 -0400 Subject: [PATCH 377/436] defaultShowPatternInfo is now set to false --- config/config.yml.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml.default b/config/config.yml.default index 9dfecd30..7f383570 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -42,4 +42,4 @@ sourceDir: "source" defaultPattern: "all" # show pattern info by default on the "view all" views -defaultShowPatternInfo: true +defaultShowPatternInfo: false From 6c122f8b81d57b9d6b5a20135dc80cc6bdab1852 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 14:15:16 -0400 Subject: [PATCH 378/436] tweaking static class calls in the exporters --- .../Exporters/DataLinkExporter.php | 7 ++-- .../Exporters/DataMergeExporter.php | 33 ++++++++++--------- .../Exporters/NavItemsExporter.php | 14 ++++---- .../Exporters/PatternPartialsExporter.php | 17 ++++++---- .../Exporters/PatternPathDestsExporter.php | 7 ++-- .../Exporters/PatternPathSrcExporter.php | 7 ++-- .../Exporters/ViewAllPathsExporter.php | 7 ++-- 7 files changed, 57 insertions(+), 35 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php index 9ff86a6c..fdd875eb 100644 --- a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php +++ b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php @@ -18,16 +18,19 @@ class DataLinkExporter extends \PatternLab\PatternData\Exporter { + protected $store; + public function __construct($options = array()) { parent::__construct($options); + $this->store = PatternData::get(); + } public function run() { - $store = PatternData::get(); - foreach ($store as $patternStoreKey => $patternStoreData) { + foreach ($this->store as $patternStoreKey => $patternStoreData) { if ($patternStoreData["category"] == "pattern") { diff --git a/src/PatternLab/PatternData/Exporters/DataMergeExporter.php b/src/PatternLab/PatternData/Exporters/DataMergeExporter.php index 39d683ed..8bccd9e1 100644 --- a/src/PatternLab/PatternData/Exporters/DataMergeExporter.php +++ b/src/PatternLab/PatternData/Exporters/DataMergeExporter.php @@ -18,39 +18,42 @@ use \PatternLab\Timer; class DataMergeExporter extends \PatternLab\PatternData\Exporter { - + + protected $store; + public function __construct($options = array()) { - + parent::__construct($options); - + + $this->store = PatternData::get(); + } - + public function run() { - - $store = PatternData::get(); - foreach ($store as $patternStoreKey => $patternStoreData) { - + + foreach ($this->store as $patternStoreKey => $patternStoreData) { + if ($patternStoreData["category"] == "pattern") { - + if (isset($patternStoreData["data"]) || isset($patternStoreData["listItems"])) { Data::initPattern($patternStoreKey); } - + if (isset($patternStoreData["data"])) { Data::setPatternData($patternStoreKey, $patternStoreData["data"]); } - + if (isset($patternStoreData["listItems"])) { Data::setPatternListItems($patternStoreKey, $patternStoreData["listItems"]); } - + } - + } - + // walk across the data and change link.pattern-partial to real source Data::compareReplaceListVarsInit(); - + } } diff --git a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php index e09c2eb2..75467deb 100644 --- a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php +++ b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php @@ -18,10 +18,16 @@ class NavItemsExporter extends \PatternLab\PatternData\Exporter { + protected $store; + protected $styleGuideExcludes; + public function __construct($options = array()) { parent::__construct($options); + $this->store = PatternData::get(); + $this->styleGuideExcludes = Config::getOption("styleGuideExcludes"); + } public function run() { @@ -36,8 +42,7 @@ public function run() { $navItems["patternTypes"] = array(); // iterate over the different categories and add them to the navigation - $store = PatternData::get(); - foreach ($store as $patternStoreKey => $patternStoreData) { + foreach ($this->store as $patternStoreKey => $patternStoreData) { if ($patternStoreData["category"] == "patternType") { @@ -96,9 +101,6 @@ public function run() { } - // default vars - $styleGuideExcludes = Config::getOption("styleGuideExcludes"); - // review each subtype. add a view all link or remove the subtype as necessary foreach ($navItems["patternTypes"] as $patternTypeKey => $patternTypeValues) { @@ -106,7 +108,7 @@ public function run() { $patternType = $patternTypeValues["patternType"]; $patternTypeDash = $patternTypeValues["patternTypeDash"]; - if (!in_array($patternType,$styleGuideExcludes)) { + if (!in_array($patternType,$this->styleGuideExcludes)) { foreach ($patternTypeValues["patternTypeItems"] as $patternSubtypeKey => $patternSubtypeValues) { diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index b3562d9b..a2fbba57 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -19,9 +19,16 @@ class PatternPartialsExporter extends \PatternLab\PatternData\Exporter { + protected $store; + protected $cacheBuster; + protected $styleGuideExcludes; + public function __construct($options = array()) { parent::__construct($options); + $this->store = PatternData::get(); + $this->cacheBuster = Data::getOption("cacheBuster"); + $this->styleGuideExcludes = Config::getOption("styleGuideExcludes"); } @@ -37,12 +44,10 @@ public function run($type = "", $subtype = "") { // default vars $patternPartials = array(); - $styleGuideExcludes = Config::getOption("styleGuideExcludes"); - $store = PatternData::get(); - foreach ($store as $patternStoreKey => $patternStoreData) { + foreach ($this->store as $patternStoreKey => $patternStoreData) { - if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { @@ -81,7 +86,7 @@ public function run($type = "", $subtype = "") { } - } else if (($patternStoreData["category"] == "patternSubtype") && (!in_array($patternStoreData["type"],$styleGuideExcludes))) { + } else if (($patternStoreData["category"] == "patternSubtype") && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) { @@ -100,7 +105,7 @@ public function run($type = "", $subtype = "") { } - return array("partials" => $patternPartials, "cacheBuster" => Data::getOption("cacheBuster")); + return array("partials" => $patternPartials, "cacheBuster" => $this->cacheBuster); } diff --git a/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php index bacf386d..48cc03de 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php @@ -18,18 +18,21 @@ class PatternPathDestsExporter extends \PatternLab\PatternData\Exporter { + protected $store; + public function __construct($options = array()) { parent::__construct($options); + $this->store = PatternData::get(); + } public function run() { $patternPathDests = array(); - $store = PatternData::get(); - foreach ($store as $patternStoreKey => $patternStoreData) { + foreach ($this->store as $patternStoreKey => $patternStoreData) { if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { diff --git a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php index a36ad8fc..fa9c41fd 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php @@ -19,18 +19,21 @@ class PatternPathSrcExporter extends \PatternLab\PatternData\Exporter { + protected $store; + public function __construct($options = array()) { parent::__construct($options); + $this->store = PatternData::get(); + } public function run() { $patternPathDests = array(); - $store = PatternData::get(); - foreach ($store as $patternStoreKey => $patternStoreData) { + foreach ($this->store as $patternStoreKey => $patternStoreData) { if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["nameDash"])) { diff --git a/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php b/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php index 9c68185e..8306c047 100644 --- a/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php +++ b/src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php @@ -18,24 +18,27 @@ class ViewAllPathsExporter extends \PatternLab\PatternData\Exporter { + protected $styleGuideExcludes; + public function __construct($options = array()) { parent::__construct($options); + $this->styleGuideExcludes = Config::getOption("styleGuideExcludes"); + } public function run($navItems) { // default vars $viewAllPaths = array(); - $styleGuideExcludes = Config::getOption("styleGuideExcludes"); foreach ($navItems["patternTypes"] as $patternTypeKey => $patternTypeValues) { $patternType = $patternTypeValues["patternType"]; $patternTypeDash = $patternTypeValues["patternTypeDash"]; - if (!in_array($patternType,$styleGuideExcludes)) { + if (!in_array($patternType,$this->styleGuideExcludes)) { foreach ($patternTypeValues["patternTypeItems"] as $patternSubtypeKey => $patternSubtypeValues) { From 67c193d17442f0d4b01409c9eac8e28784ff1133 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 15:17:11 -0400 Subject: [PATCH 379/436] processing the header and footer with the patternLoader --- src/PatternLab/Builder.php | 58 +++++++++++++------ .../PatternData/Helpers/PatternCodeHelper.php | 4 +- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index cd29c8c0..fd3a83a4 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -21,6 +21,7 @@ use \PatternLab\PatternData\Exporters\NavItemsExporter; use \PatternLab\PatternData\Exporters\PatternPartialsExporter; use \PatternLab\PatternData\Exporters\PatternPathDestsExporter; +use \PatternLab\PatternData\Exporters\PatternPathSrcExporter; use \PatternLab\PatternData\Exporters\ViewAllPathsExporter; use \PatternLab\PatternEngine; use \PatternLab\Template; @@ -261,6 +262,15 @@ protected function generateStyleguide() { // default var $publicDir = Config::getOption("publicDir"); + // load the pattern loader + $ppdExporter = new PatternPathSrcExporter(); + $patternPathSrc = $ppdExporter->run(); + $options = array(); + $options["patternPaths"] = $patternPathSrc; + $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); + $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; + $patternLoader = new $patternLoaderClass($options); + // check directories i need if (!is_dir($publicDir."/styleguide/")) { mkdir($publicDir."/styleguide/"); @@ -271,24 +281,26 @@ protected function generateStyleguide() { } // grab the partials into a data object for the style guide - $ppExporter = new PatternPartialsExporter(); - $partials = $ppExporter->run(); + $ppExporter = new PatternPartialsExporter(); + $partials = $ppExporter->run(); // add the pattern data so it can be exported $patternData = array(); // add the pattern lab specific mark-up - $filesystemLoader = Template::getFilesystemLoader(); - $stringLoader = Template::getStringLoader(); + $filesystemLoader = Template::getFilesystemLoader(); + $stringLoader = Template::getStringLoader(); - $partials["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); - $partials["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); + $globalData = Data::get(); + $globalData["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); + $globalData["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); + $globalData["viewall"] = true; - $header = $stringLoader->render(array("string" => Template::getPatternHead(), "data" => $partials)); - $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); - $footer = $stringLoader->render(array("string" => Template::getPatternFoot(), "data" => $partials)); + $header = $patternLoader->render(array("pattern" => Template::getPatternHead(), "data" => $globalData)); + $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); + $footer = $patternLoader->render(array("pattern" => Template::getPatternFoot(), "data" => $globalData)); - $styleGuidePage = $header.$code.$footer; + $styleGuidePage = $header.$code.$footer; file_put_contents($publicDir."/styleguide/html/styleguide.html",$styleGuidePage); @@ -316,6 +328,19 @@ protected function generateViewAllPages() { $patternFoot = Template::getPatternFoot(); $filesystemLoader = Template::getFilesystemLoader(); $stringLoader = Template::getStringLoader(); + $globalData = Data::get(); + + // load the pattern loader + $ppdExporter = new PatternPathSrcExporter(); + $patternPathSrc = $ppdExporter->run(); + $options = array(); + $options["patternPaths"] = $patternPathSrc; + $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); + $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; + $patternLoader = new $patternLoaderClass($options); + + // make sure view all is set + $globalData["viewall"] = true; // make sure the pattern dir exists if (!is_dir($patternPublicDir)) { @@ -338,14 +363,13 @@ protected function generateViewAllPages() { $patternData = array(); $patternData["patternPartial"] = "viewall-".$patternStoreData["typeDash"]."-".$patternStoreData["nameDash"]; - // add the pattern lab specific mark-up - $partials["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); - $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); + $globalData["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); + $globalData["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them - $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); + $header = $patternLoader->render(array("pattern" => $patternHead, "data" => $globalData)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); - $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); + $footer = $patternLoader->render(array("pattern" => $patternFoot, "data" => $globalData)); $viewAllPage = $header.$code.$footer; // if the pattern directory doesn't exist create it @@ -376,9 +400,9 @@ protected function generateViewAllPages() { $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them - $header = $stringLoader->render(array("string" => $patternHead, "data" => $partials)); + $header = $patternLoader->render(array("pattern" => $patternHead, "data" => $globalData)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); - $footer = $stringLoader->render(array("string" => $patternFoot, "data" => $partials)); + $footer = $patternLoader->render(array("pattern" => $patternFoot, "data" => $globalData)); $viewAllPage = $header.$code.$footer; // if the pattern directory doesn't exist create it diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 0dccb141..3e910dfd 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -85,9 +85,9 @@ public function run() { if (isset($patternStoreData["patternRaw"])) { - $header = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternHead, "data" => $data)) : ""; + $header = (!$this->exportClean) ? $patternLoader->render(array("pattern" => $patternHead, "data" => $data)) : ""; $code = $patternLoader->render(array("pattern" => $patternStoreData["patternRaw"], "data" => $data)); - $footer = (!$this->exportClean) ? $stringLoader->render(array("string" => $patternFoot, "data" => $data)) : ""; + $footer = (!$this->exportClean) ? $patternLoader->render(array("pattern" => $patternFoot, "data" => $data)) : ""; PatternData::setPatternOption($patternStoreKey,"header",$header); PatternData::setPatternOption($patternStoreKey,"code",$code); From 7d18615ddc5af56ad7e6f77efd070e859cbe4901 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 21:57:49 -0400 Subject: [PATCH 380/436] reconfiguring the timeouts --- .../Console/Commands/ServerCommand.php | 4 ++-- src/PatternLab/Console/ProcessSpawner.php | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/PatternLab/Console/Commands/ServerCommand.php b/src/PatternLab/Console/Commands/ServerCommand.php index 12c5a983..1e4d1664 100644 --- a/src/PatternLab/Console/Commands/ServerCommand.php +++ b/src/PatternLab/Console/Commands/ServerCommand.php @@ -58,12 +58,12 @@ public function run() { // set-up the base command $command = $this->pathPHP." -S ".$host." ".$coreDir."/server/router.php"; $commands = array(); - $commands[] = array("command" => $command, "cwd" => $publicDir, "timeout" => null, "idle" => 600); + $commands[] = array("command" => $command, "cwd" => $publicDir, "timeout" => null, "idle" => 1800); // get the watch command info if (Console::findCommandOption("with-watch")) { $watchCommand = new WatchCommand; - $commands[] = array("command" => $watchCommand->build()." --no-procs", "timeout" => null, "idle" => 600); + $commands[] = array("command" => $watchCommand->build()." --no-procs", "timeout" => null, "idle" => 1800); } Console::writeInfo("server started on http://".$host." - use ctrl+c to exit..."); diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php index 6baca5ef..c991881c 100644 --- a/src/PatternLab/Console/ProcessSpawner.php +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -19,8 +19,10 @@ use \PatternLab\Console\ProcessSpawnerEvent; use \PatternLab\Dispatcher; use \PatternLab\Timer; +use \Symfony\Component\Process\Exception\ProcessTimedOutException; use \Symfony\Component\Process\Process; + class ProcessSpawner { protected $pluginProcesses; @@ -63,13 +65,9 @@ public function spawn($commands = array(), $quiet = false) { // if there are processes to spawn do so if (!empty($processes)) { - // get the time out - $timeout = Config::getOption("timeout") ? (int)Config::getOption("timeout") : 3600; - // start the processes foreach ($processes as $process) { $process["process"]->start(); - $process["process"]->setTimeout($timeout); } // check on them and produce output @@ -83,8 +81,12 @@ public function spawn($commands = array(), $quiet = false) { print $process["process"]->getIncrementalErrorOutput(); } } - } catch (\RuntimeException $e) { - Console::writeError("pattern lab processes automatically time out after ".$timeout." seconds..."); + } catch (ProcessTimedOutException $e) { + if ($e->isGeneralTimeout()) { + Console::writeError("pattern lab processes should never time out. yours did..."); + } else if ($e->isIdleTimeout()) { + Console::writeError("pattern lab processes automatically time out if their is no command line output in 30 minutes..."); + } } } usleep(100000); @@ -110,7 +112,7 @@ protected function buildProcess($commandOptions) { $cwd = isset($commandOptions["cwd"]) ? $commandOptions["cwd"] : null; $env = isset($commandOptions["env"]) ? $commandOptions["env"] : null; $input = isset($commandOptions["input"]) ? $commandOptions["input"] : null; - $timeout = isset($commandOptions["timeout"]) ? $commandOptions["timeout"] : 60; + $timeout = isset($commandOptions["timeout"]) ? $commandOptions["timeout"] : null; $options = isset($commandOptions["options"]) ? $commandOptions["options"] : array(); $idle = isset($commandOptions["idle"]) ? $commandOptions["idle"] : null; $output = isset($commandOptions["output"]) ? $commandOptions["output"] : true; From c5addcc31c41b299f8386eb00334feedac904f40 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 22:01:20 -0400 Subject: [PATCH 381/436] removing error color from sayings --- src/PatternLab/Saying.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/Saying.php b/src/PatternLab/Saying.php index 46d96071..86a9b1fe 100644 --- a/src/PatternLab/Saying.php +++ b/src/PatternLab/Saying.php @@ -90,7 +90,7 @@ public function __construct() { public function say() { // set a color - $colors = array("ok","options","info","warning","error"); + $colors = array("ok","options","info","warning"); $randomNumber = rand(0,count($colors)-1); $color = (isset($colors[$randomNumber])) ? $colors[$randomNumber] : "desc"; From 500cc37e7f8ab39020a20903fc0ed99035facc25 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 23:02:54 -0400 Subject: [PATCH 382/436] updating the version number --- config/config.yml.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml.default b/config/config.yml.default index 7f383570..5b9c5a96 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -1,7 +1,7 @@ ## Configuration Options for Pattern Lab # pattern lab version -v: "2.5.0" +v: "2.6.0" # what to do when included config var conflicts, q for question, a for always override, n for never override overrideConfig: "q" From 3a6fd6ee68012274b47364c506c6039c4bd4b6b6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Tue, 12 Jul 2016 23:46:27 -0400 Subject: [PATCH 383/436] ignoring patternlab-components when checking for an empty public dir --- src/PatternLab/Fetch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index afeb633e..4da75d26 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -68,7 +68,7 @@ public function fetchStarterKit($starterkit = "") { //get the path to the GH repo and validate it $tarballUrl = "https://github.com/".$org."/".$repo."/archive/".$tag.".tar.gz"; - Console::writeInfo("downloading the starterkit..."); + Console::writeInfo("downloading the starterkit. this may take a few minutes..."); // try to download the given package if (!$package = @file_get_contents($tarballUrl)) { @@ -177,7 +177,7 @@ protected function mirrorDist($sourceDir, $tempDirDist) { // set default vars $fsOptions = array(); $emptyDir = true; - $validFiles = array("README",".gitkeep",".DS_Store","styleguide"); + $validFiles = array("README",".gitkeep",".DS_Store","styleguide","patternlab-components"); // see if the source directory is empty if (is_dir($sourceDir)) { From 69d17f8c2139d96f611c6db6787a77cbebeb6651 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 13 Jul 2016 00:00:59 -0400 Subject: [PATCH 384/436] changing the order of package/starterkit/config install --- src/PatternLab/InstallerUtil.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 3ea55311..05984f0f 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -591,11 +591,6 @@ protected static function packagesInstall($installerInfo, $event) { // initialize a bunch of stuff like config and console self::init(); - // make sure user is prompted to install starterkit - if (!empty($installerInfo["suggestedStarterKits"])) { - self::promptStarterKitInstall($installerInfo["suggestedStarterKits"]); - } - // reorder packages so the starterkit is first if it's being installed as a package if (isset($installerInfo["packages"])) { @@ -633,6 +628,11 @@ protected static function packagesInstall($installerInfo, $event) { } + // make sure user is prompted to install starterkit + if (!empty($installerInfo["suggestedStarterKits"])) { + self::promptStarterKitInstall($installerInfo["suggestedStarterKits"]); + } + // override any configs that have been set-up if (!empty($installerInfo["configOverrides"])) { foreach ($installerInfo["configOverrides"] as $option => $value) { From f30592d1e461a4b27c210191a2ac278280db3e1c Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 13 Jul 2016 00:10:34 -0400 Subject: [PATCH 385/436] making sure patternlab-components is ignored --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 05984f0f..66a3fab5 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -468,7 +468,7 @@ protected static function pathExists($packageName,$path) { // see if the directory is essentially empty $files = scandir($path); foreach ($files as $key => $file) { - $ignore = array("..",".",".gitkeep","README",".DS_Store"); + $ignore = array("..",".",".gitkeep","README",".DS_Store","patternlab-components"); $file = explode("/",$file); if (in_array($file[count($file)-1],$ignore)) { unset($files[$key]); From 23e9c81d5d1370d3e2009dbf00d4e4159baa4818 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Wed, 13 Jul 2016 20:03:38 -0400 Subject: [PATCH 386/436] handle a mismatch between an underscored pattern and data file --- src/PatternLab/PatternData/Helpers/PatternCodeHelper.php | 2 +- src/PatternLab/PatternData/Helpers/RawPatternHelper.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php index 3e910dfd..da6879be 100644 --- a/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternCodeHelper.php @@ -57,7 +57,7 @@ public function run() { // iterate to process each pattern foreach ($store as $patternStoreKey => $patternStoreData) { - if ($patternStoreData["category"] == "pattern") { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["name"])) { $data = Data::getPatternSpecificData($patternStoreKey); diff --git a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php index 9c2de8c5..17446591 100644 --- a/src/PatternLab/PatternData/Helpers/RawPatternHelper.php +++ b/src/PatternLab/PatternData/Helpers/RawPatternHelper.php @@ -41,7 +41,7 @@ public function run() { // iterate to get raw data loaded into the PatternData Store foreach ($store as $patternStoreKey => $patternStoreData) { - if ($patternStoreData["category"] == "pattern") { + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["name"])) { // figure out the source path for the pattern to render $srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"]; @@ -51,7 +51,7 @@ public function run() { if (file_exists($path)) { PatternData::setPatternOption($patternStoreKey,"patternRaw",file_get_contents($path)); } else { - Console::writeError($patternStoreData["partial"]." wasn't found for loading. the given path: ".$path); + Console::writeWarning($patternStoreData["partial"]." wasn't found for loading. the given path: ".$path); } } From 2eca64aa70480e849ae33a20826302365aab9324 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 22:34:55 -0400 Subject: [PATCH 387/436] making sure markdown documentation is trimmed --- src/PatternLab/PatternData/Rules/DocumentationRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index b391e2f6..4e9ef3fa 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -75,7 +75,7 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternStoreKey = ($patternSubtypeDoc) ? $docPartial."-plsubtype" : $docPartial; $patternStoreData = array("category" => $category, - "desc" => $markdown, + "desc" => trim($markdown), "descExists" => true, "meta" => $yaml, "full" => $doc); From 3bba5702197d8678ddaa7ca8977f54678159fff1 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 22:49:09 -0400 Subject: [PATCH 388/436] got used to the server being quiet all the time --- src/PatternLab/Console/ProcessSpawner.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console/ProcessSpawner.php b/src/PatternLab/Console/ProcessSpawner.php index c991881c..3b32050a 100644 --- a/src/PatternLab/Console/ProcessSpawner.php +++ b/src/PatternLab/Console/ProcessSpawner.php @@ -78,7 +78,10 @@ public function spawn($commands = array(), $quiet = false) { $process["process"]->checkTimeout(); if (!$quiet && $process["output"]) { print $process["process"]->getIncrementalOutput(); - print $process["process"]->getIncrementalErrorOutput(); + $cmd = $process["process"]->getCommandLine(); + if (strpos($cmd,"router.php") != (strlen($cmd) - 10)) { + print $process["process"]->getIncrementalErrorOutput(); + } } } } catch (ProcessTimedOutException $e) { From 2dd0d83fb623ecb35d561313e12f5e7e0a302ca0 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:12:46 -0400 Subject: [PATCH 389/436] cleaning up phpBin help and humanReadablePath example --- src/PatternLab/Console.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index e17850c0..5110040f 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -174,7 +174,8 @@ public static function getPathPHP() { if (!$path) { $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); - Console::writeError("please add the option `phpBin` with the path to PHP to ".$configPath." to run this process..."); + $examplePHP = (DIRECTORY_SEPARATOR === "/") ? "C:\wamp\bin\php\php5.5.12" : "/opt/local/lib/php54"; + Console::writeError("can't find PHP. add the path to PHP by adding the option \"phpBin\" to ".$configPath.". it should look like \"phpBin\": \"".$examplePHP."\""); } return $path; @@ -192,7 +193,7 @@ public static function getPathConsole() { if (!$console) { $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); - Console::writeError("please add the option `phpScriptName` with the path to your console option (e.g. core/console) to ".$configPath." to run this process..."); + Console::writeError("please add the option `phpScriptName` with the path to your console option (e.g. core".DIRECTORY_SEPARATOR."console) to ".$configPath." to run this process..."); } return Config::getOption("baseDir").$console; @@ -479,7 +480,7 @@ public static function getSpacer($lengthLong,$itemLongLength) { * @return {String} cleaned up path */ public static function getHumanReadablePath($path) { - return str_replace(Config::getOption("baseDir"), "./", $path); + return str_replace(Config::getOption("baseDir"), ".".DIRECTORY_SEPARATOR, $path); } /** From 255ee1274be449f023faebd052fdb443fb1d3f34 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:24:07 -0400 Subject: [PATCH 390/436] catching the zippy failure --- src/PatternLab/Fetch.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index 4da75d26..efd1969e 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -96,10 +96,14 @@ public function fetchStarterKit($starterkit = "") { } // extract, if the zip is supposed to be unpacked do that (e.g. stripdir) - $zippy = Zippy::load(); - $zippy->addStrategy(new UnpackFileStrategy()); - $zippy->getAdapterFor('tar.gz')->open($tempFile)->extract($tempDirSK); - + try { + $zippy = Zippy::load(); + $zippy->addStrategy(new UnpackFileStrategy()); + $zippy->getAdapterFor('tar.gz')->open($tempFile)->extract($tempDirSK); + } catch(\RuntimeException $e) { + Console::writeError("failed to extract the starterkit. easiest solution is to manually download it and copy ./dist./source/
..."); + } + if (!is_dir($tempDirDist)) { // try without repo dir $tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist"; From ae116c7bbe83bd9dbf0b7c8161f08934585dcf4e Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:26:45 -0400 Subject: [PATCH 391/436] removing unused command and code --- .../Console/Commands/FetchCommand.php | 63 ------------------- src/PatternLab/Fetch.php | 18 ------ 2 files changed, 81 deletions(-) delete mode 100644 src/PatternLab/Console/Commands/FetchCommand.php diff --git a/src/PatternLab/Console/Commands/FetchCommand.php b/src/PatternLab/Console/Commands/FetchCommand.php deleted file mode 100644 index 6ede1e0b..00000000 --- a/src/PatternLab/Console/Commands/FetchCommand.php +++ /dev/null @@ -1,63 +0,0 @@ -command = "fetch"; - - Console::setCommand($this->command,"Fetch a package or StarterKit","The fetch command downloads packages and StarterKits.","f"); - Console::setCommandOption($this->command,"package:","Fetch a package from Packagist.","To fetch a package from Packagist:","p:",""); - - } - - public function run() { - - // find the value given to the command - $package = Console::findCommandOptionValue("p|package"); - - if ($package) { - - // if was passed ask the user for the package name - if ($package == "prompt") { - $prompt = "what is the name of the package you want to fetch?"; - $options = "(ex. pattern-lab/plugin-kss)"; - $package = Console::promptInput($prompt,$options); - } - - // make sure it looks like a valid package - if (strpos($package,"/") === false) { - Console::writeError("that wasn't a valid package name. it should look like pattern-lab/plugin-kss..."); - } - - // run composer via fetch - $f = new Fetch(); - $f->fetchPackage($package); - - } else { - - Console::writeHelpCommand($this->command); - - } - - } - -} diff --git a/src/PatternLab/Fetch.php b/src/PatternLab/Fetch.php index efd1969e..d13ee936 100644 --- a/src/PatternLab/Fetch.php +++ b/src/PatternLab/Fetch.php @@ -23,24 +23,6 @@ class Fetch { - /** - * Fetch a package using Composer - * @param {String} the path to the package to be downloaded - * - * @return {String} the modified file contents - */ - public function fetchPackage($package = "") { - - if (empty($package)) { - Console::writeError("please provide a path for the package before trying to fetch it..."); - } - - // run composer - $composerPath = Config::getOption("coreDir").DIRECTORY_SEPARATOR."bin/composer.phar"; - passthru("php ".$composerPath." require ".$package); - - } - /** * Fetch a package from GitHub * @param {String} the command option to provide the rule for From 2d577a1b61fda383ec4e32cb587aeb110f97c5a6 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:50:56 -0400 Subject: [PATCH 392/436] remove warning about annotations dir --- src/PatternLab/Annotations.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/PatternLab/Annotations.php b/src/PatternLab/Annotations.php index 8378009e..d26e605f 100644 --- a/src/PatternLab/Annotations.php +++ b/src/PatternLab/Annotations.php @@ -51,13 +51,9 @@ public static function gather() { // set-up the comments store self::$store["comments"] = array(); - // iterate over all of the files in the annotations dir + // create the annotations dir if it doesn't exist if (!is_dir($annotationsDir)) { - Console::writeWarning("".Console::getHumanReadablePath($annotationsDir)." doesn't exist so you won't have annotations..."); mkdir($annotationsDir); - } else { - - } // find the markdown-based annotations From 78de35869db6f27be8f92d0fb8b19c7338335f10 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:52:13 -0400 Subject: [PATCH 393/436] removing some of the old CSS rule saver code --- src/PatternLab/Builder.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index fd3a83a4..3c94fccd 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -35,8 +35,6 @@ class Builder { */ public function __construct() { - //$this->patternCSS = array(); - // set-up the pattern engine PatternEngine::init(); @@ -425,21 +423,4 @@ protected function generateViewAllPages() { } - /** - * Loads the CSS from source/css/ into CSS Rule Saver to be used for code view - * Will eventually get pushed elsewhere - */ - protected function initializeCSSRuleSaver() { - - $loader = new \SplClassLoader('CSSRuleSaver', __DIR__.'/../../lib'); - $loader->register(); - - $this->cssRuleSaver = new \CSSRuleSaver\CSSRuleSaver; - - foreach(glob(Config::getOption("sourceDir")."/css/*.css") as $filename) { - $this->cssRuleSaver->loadCSS($filename); - } - - } - } From 848fea2eeac1c9c28d37b3f727ec698536685b8b Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:52:37 -0400 Subject: [PATCH 394/436] removing some more of the old CSS code --- src/PatternLab/Builder.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 3c94fccd..5c3444a5 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -230,12 +230,6 @@ protected function generatePatterns($options = array()) { file_put_contents($patternPublicDir."/".$path."/".$path.".markup-only.html",$markup); file_put_contents($patternPublicDir."/".$path."/".$path.".".$patternExtension,$markupEngine); } - /* - Not being used and should be moved to a plug-in - if (Config::$options["enableCSS"] && isset($this->patternCSS[$p])) { - file_put_contents($patternPublicDir.$path."/".$path.".css",htmlentities($this->patternCSS[$p])); - } - */ } From 33acdc99717d8b8e9bf29e4765a4a13983a02b0f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Fri, 15 Jul 2016 23:55:44 -0400 Subject: [PATCH 395/436] adding new lines for clarity when looking at pattern lab data.js --- src/PatternLab/Builder.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 5c3444a5..f114853f 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -106,7 +106,7 @@ protected function generateIndex() { foreach ($exposedOptions as $exposedOption) { $config[$exposedOption] = Config::getOption($exposedOption); } - $output .= "var config = ".json_encode($config).";"; + $output .= "var config = ".json_encode($config).";\n"; // load the ish Controls $ishControls = array(); @@ -118,24 +118,24 @@ protected function generateIndex() { } } $ishControls["ishControlsHide"] = $controlsToHide; - $output .= "var ishControls = ".json_encode($ishControls).";"; + $output .= "var ishControls = ".json_encode($ishControls).";\n"; // load and write out the items for the navigation $niExporter = new NavItemsExporter(); $navItems = $niExporter->run(); - $output .= "var navItems = ".json_encode($navItems).";"; + $output .= "var navItems = ".json_encode($navItems).";\n"; // load and write out the items for the pattern paths $patternPaths = array(); $ppdExporter = new PatternPathDestsExporter(); $patternPaths = $ppdExporter->run(); - $output .= "var patternPaths = ".json_encode($patternPaths).";"; + $output .= "var patternPaths = ".json_encode($patternPaths).";\n"; // load and write out the items for the view all paths $viewAllPaths = array(); $vapExporter = new ViewAllPathsExporter(); $viewAllPaths = $vapExporter->run($navItems); - $output .= "var viewAllPaths = ".json_encode($viewAllPaths).";"; + $output .= "var viewAllPaths = ".json_encode($viewAllPaths).";\n"; // gather plugin package information $packagesInfo = array(); From 4efad0edf21af802f4ba629cddbe6bf093889704 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 21 Jul 2016 21:27:45 -0400 Subject: [PATCH 396/436] adding support to push outputSuffixes --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 8393e3b2..9a27aeea 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -241,6 +241,7 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); self::setExposedOption("patternExtension"); + self::setExposedOption("outputFileSuffixes"); self::setExposedOption("plugins"); } From 6625458242e6396b91359bf8841132f24f18f56f Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 21 Jul 2016 21:28:06 -0400 Subject: [PATCH 397/436] removing exposure of patternExtension --- src/PatternLab/Config.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 9a27aeea..44f24bd5 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -240,7 +240,6 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("ishFontSize"); self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); - self::setExposedOption("patternExtension"); self::setExposedOption("outputFileSuffixes"); self::setExposedOption("plugins"); From 1aa2725272416562ba97012fba97a01766b8cb16 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 21 Jul 2016 21:37:36 -0400 Subject: [PATCH 398/436] adding output file suffixes to config --- src/PatternLab/Config.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 44f24bd5..b07e90e3 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -212,6 +212,11 @@ public static function init($baseDir = "", $verbose = true) { self::$options["metaDir"] = isset(self::$options["metaDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["metaDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_meta/"; self::$options["annotationsDir"] = isset(self::$options["annotationsDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["annotationsDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_annotations/"; + // set-up outputFileSuffixes + self::$options["outputFileSuffixes"]["rendered"] = isset(self::$options["outputFileSuffixes"]["rendered"]) ? self::$options["outputFileSuffixes"]["rendered"] : ''; + self::$options["outputFileSuffixes"]["rawTemplate"] = isset(self::$options["outputFileSuffixes"]["rawTemplate"]) ? self::$options["outputFileSuffixes"]["rawTemplate"] : ''; + self::$options["outputFileSuffixes"]["markupOnly"] = isset(self::$options["outputFileSuffixes"]["markupOnly"]) ? self::$options["outputFileSuffixes"]["markupOnly"] : '.markup-only'; + // handle a pre-2.1.0 styleguideKitPath before saving it if (isset(self::$options["styleguideKitPath"])) { self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"])); From 9204dc32852963b9c3092ee125ed352d6b0a9980 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 21 Jul 2016 22:34:11 -0400 Subject: [PATCH 399/436] implementing suffix paths --- src/PatternLab/Builder.php | 9 ++++++--- .../PatternData/Exporters/NavItemsExporter.php | 3 ++- .../PatternData/Exporters/PatternPartialsExporter.php | 3 ++- .../PatternData/Exporters/PatternPathSrcExporter.php | 2 +- src/PatternLab/PatternData/Helpers/LineageHelper.php | 5 +++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index f114853f..a869e329 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -194,6 +194,9 @@ protected function generatePatterns($options = array()) { $patternPublicDir = !$exportFiles ? Config::getOption("patternPublicDir") : Config::getOption("patternExportDir"); $patternSourceDir = Config::getOption("patternSourceDir"); $patternExtension = Config::getOption("patternExtension"); + $suffixRendered = Config::getOption("outputFileSuffixes.rendered"); + $suffixRaw = Config::getOption("outputFileSuffixes.rawTemplate"); + $suffixMarkupOnly = Config::getOption("outputFileSuffixes.markupOnly"); // make sure the export dir exists if ($exportFiles && !is_dir($exportDir)) { @@ -225,10 +228,10 @@ protected function generatePatterns($options = array()) { } // write out the various pattern files - file_put_contents($patternPublicDir."/".$path."/".$path.".html",$markupFull); + file_put_contents($patternPublicDir."/".$path."/".$path.$suffixRendered.".html",$markupFull); if (!$exportFiles) { - file_put_contents($patternPublicDir."/".$path."/".$path.".markup-only.html",$markup); - file_put_contents($patternPublicDir."/".$path."/".$path.".".$patternExtension,$markupEngine); + file_put_contents($patternPublicDir."/".$path."/".$path.$suffixMarkupOnly.".html",$markup); + file_put_contents($patternPublicDir."/".$path."/".$path.$suffixRaw.".".$patternExtension,$markupEngine); } } diff --git a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php index 75467deb..43db5694 100644 --- a/src/PatternLab/PatternData/Exporters/NavItemsExporter.php +++ b/src/PatternLab/PatternData/Exporters/NavItemsExporter.php @@ -37,6 +37,7 @@ public function run() { $patternSubtypeSet = false; $patternType = ""; $patternTypeDash = ""; + $suffixRendered = Config::getOption("outputFileSuffixes.rendered"); $navItems = array(); $navItems["patternTypes"] = array(); @@ -82,7 +83,7 @@ public function run() { if (isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) { // set-up the info for the nav - $patternInfo = array("patternPath" => $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html", + $patternInfo = array("patternPath" => $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].$suffixRendered.".html", "patternSrcPath" => $patternStoreData["pathName"], "patternName" => ucwords($patternStoreData["nameClean"]), "patternState" => $patternStoreData["state"], diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index a2fbba57..14d7ab08 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -44,6 +44,7 @@ public function run($type = "", $subtype = "") { // default vars $patternPartials = array(); + $suffixRendered = Config::getOption("outputFileSuffixes.rendered"); foreach ($this->store as $patternStoreKey => $patternStoreData) { @@ -53,7 +54,7 @@ public function run($type = "", $subtype = "") { $patternPartialData = array(); $patternPartialData["patternName"] = $patternStoreData["nameClean"]; - $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; + $patternPartialData["patternLink"] = $patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].$suffixRendered.".html"; $patternPartialData["patternPartial"] = $patternStoreData["partial"]; $patternPartialData["patternPartialCode"] = $patternStoreData["code"]; $patternPartialData["patternState"] = $patternStoreData["state"]; diff --git a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php index fa9c41fd..6c372e98 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php @@ -44,7 +44,7 @@ public function run() { $patternPathDests[$typeDash] = array(); } - $patternPathDests[$typeDash][$nameDash] = (isset($patternStoreData["pseudo"])) ? $patternStoreData["pathOrig"] : $patternStoreData["pathName"];; + $patternPathDests[$typeDash][$nameDash] = (isset($patternStoreData["pseudo"])) ? $patternStoreData["pathOrig"] : $patternStoreData["pathName"]; } diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 97363a0c..61185d65 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -37,6 +37,7 @@ public function run() { $foundLineages = array(); $patternSourceDir = Config::getOption("patternSourceDir"); $patternExtension = Config::getOption("patternExtension"); + $suffixRendered = Config::getOption("outputFileSuffixes.rendered"); // check for the regular lineages in only normal patterns $store = PatternData::get(); @@ -55,7 +56,7 @@ public function run() { if (PatternData::getOption($lineage)) { $patternLineages[] = array("lineagePattern" => $lineage, - "lineagePath" => "../../patterns/".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"); + "lineagePath" => "../../patterns/".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].$suffixRendered.".html"); } else { @@ -124,7 +125,7 @@ public function run() { $path = PatternData::getPatternOption($haystackKey,"pathDash"); $patternLineagesR[] = array("lineagePattern" => $haystackKey, - "lineagePath" => "../../patterns/".$path."/".$path.".html"); + "lineagePath" => "../../patterns/".$path."/".$path.$suffixRendered.".html"); } From e1c0509f06bf959b242c5807c2c624833693c7ee Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 21 Jul 2016 23:00:05 -0400 Subject: [PATCH 400/436] using symfony class to find PHP --- src/PatternLab/Console.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Console.php b/src/PatternLab/Console.php index 5110040f..5b41f619 100644 --- a/src/PatternLab/Console.php +++ b/src/PatternLab/Console.php @@ -17,6 +17,7 @@ use \PatternLab\Console\Event as ConsoleEvent; use \PatternLab\Dispatcher; use \PatternLab\Timer; +use \Symfony\Component\Process\PhpExecutableFinder; class Console { @@ -170,7 +171,9 @@ public static function getCommand() { */ public static function getPathPHP() { - $path = isset($_SERVER["_"]) ? $_SERVER["_"] : Config::getOption("phpBin"); + $manualPHP = Config::getOption("phpBin"); + $autoPHP = new PhpExecutableFinder(); + $path = $manualPHP ? $manualPHP : $autoPHP->find(); if (!$path) { $configPath = Console::getHumanReadablePath(Config::getOption("configPath")); From c976fa4cbffac7a67c41df43f47899d09a965a49 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 28 Jul 2016 17:12:01 -0400 Subject: [PATCH 401/436] making sure pattern type properly loads globalData var --- src/PatternLab/Builder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index a869e329..fb91068f 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -391,8 +391,8 @@ protected function generateViewAllPages() { $patternData["patternPartial"] = "viewall-".$patternStoreData["nameDash"]."-all"; // add the pattern lab specific mark-up - $partials["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); - $partials["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); + $globalData["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); + $globalData["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); // render the parts and join them $header = $patternLoader->render(array("pattern" => $patternHead, "data" => $globalData)); From 7dd6d483c69b4684173247f9673e907621311af4 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Thu, 28 Jul 2016 17:21:37 -0400 Subject: [PATCH 402/436] install assets and save path appropriately --- src/PatternLab/InstallerUtil.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index 66a3fab5..fb934e4f 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -349,14 +349,15 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati // iterate over the returned objects foreach ($finder as $file) { - $ext = $file->getExtension(); + $ext = $file->getExtension(); + $pathName = $file->getPathname()); if ($ext == "css") { - $componentTypes["stylesheets"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); + $componentTypes["stylesheets"][] = str_replace(DIRECTORY_SEPARATOR,"/",str_replace($sourceBase.$source,$destination,$pathName)); } else if ($ext == "js") { - $componentTypes["javascripts"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); + $componentTypes["javascripts"][] = str_replace(DIRECTORY_SEPARATOR,"/",str_replace($sourceBase.$source,$destination,$pathName)); } else if ($ext == $templateExtension) { - $componentTypes["templates"][] = str_replace($sourceBase.$source,$destination,$file->getPathname()); + $componentTypes["templates"][] = str_replace(DIRECTORY_SEPARATOR,"/",str_replace($sourceBase.$source,$destination,$pathName)); } } From 884c9952ccba72e3b42afd29840a42f642e22a41 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 31 Oct 2016 12:23:36 -0700 Subject: [PATCH 403/436] Updating global data to use `yml` or `yaml` --- src/PatternLab/Data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/Data.php b/src/PatternLab/Data.php index e0da3fc7..75b05654 100644 --- a/src/PatternLab/Data.php +++ b/src/PatternLab/Data.php @@ -125,7 +125,7 @@ public static function gather($options = array()) { $pathName = $file->getPathname(); $pathNameClean = str_replace($sourceDir."/","",$pathName); - if (!$hidden && (($ext == "json") || ($ext == "yaml"))) { + if (!$hidden && (($ext == "json") || ($ext == "yaml") || ($ext == "yml"))) { if ($isListItems === false) { @@ -137,7 +137,7 @@ public static function gather($options = array()) { JSON::lastErrorMsg($pathNameClean,$jsonErrorMessage,$data); } - } else if ($ext == "yaml") { + } else if (($ext == "yaml") || ($ext == "yml")) { $file = file_get_contents($pathName); From 44c0dd0caa5ddd63a7b298ab594d3f948a08da31 Mon Sep 17 00:00:00 2001 From: Salem Ghoweri Date: Thu, 27 Apr 2017 13:31:04 -0400 Subject: [PATCH 404/436] Fixing extra closing parentheses so dev branch works. Addresses https://github.com/pattern-lab/patternlab-php-core/pull/87 --- src/PatternLab/InstallerUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PatternLab/InstallerUtil.php b/src/PatternLab/InstallerUtil.php index fb934e4f..fcc7fa99 100644 --- a/src/PatternLab/InstallerUtil.php +++ b/src/PatternLab/InstallerUtil.php @@ -350,7 +350,7 @@ protected static function parseComponentList($packageName,$sourceBase,$destinati foreach ($finder as $file) { $ext = $file->getExtension(); - $pathName = $file->getPathname()); + $pathName = $file->getPathname(); if ($ext == "css") { $componentTypes["stylesheets"][] = str_replace(DIRECTORY_SEPARATOR,"/",str_replace($sourceBase.$source,$destination,$pathName)); From d7506a09a188ed6ae3cc3fb420078d569758dbb8 Mon Sep 17 00:00:00 2001 From: Salem Ghoweri Date: Tue, 9 May 2017 22:57:33 -0400 Subject: [PATCH 405/436] Adding in lineage fix for PL when using Twig templates + line by line comments to explain my PHP chicken scratch. Addresses existing open issue https://github.com/drupal-pattern-lab/patternlab-php-core/issues/3 and corresponds with the 2nd half of work mentioned in https://github.com/drupal-pattern-lab/patternengine-php-twig/pull/1 --- .../PatternData/Helpers/LineageHelper.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 61185d65..1d5676e5 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -53,6 +53,51 @@ public function run() { foreach ($foundLineages as $lineage) { + /** + * Fix for Pattern Lab Lineages when using Twig Namespaces. + * Converts the full file path to PL-friendly shorthand so + * they are internally registered. + * + * 1. Only handle instances where we aren't or can't use the + * shorthand PL path reference in templates, specifically + * in Twig / D8 when we need to use Twig namespaces in + * our template paths. + * 2. Strip off the @ sign at the beginning of our $lineage string. + * 3. Break apart the full lineage path based on any slashes that + * may exist. + * 4. Store the length of our broken up path for reference below + * 5. Store the first part of the string up to the first slash "/" + * 6. Now grab the last part of the pattern key, based on the length + * of the path we previously exploded. + * 7. Remove any "_" from pattern Name. + * 8. Remove any potential prefixed numbers or number + dash + * combos on our Pattern Name. + * 9. Strip off the pattern path extension (.twig, + * .mustache, etc) if it exists. + * 10. If the pattern name parsed had an extension, + * re-assign our Pattern Name to that. + * 11. Finally, re-assign $lineage to the default PL pattern key. + */ + + if ($lineage[0] == '@') { /* [1] */ + $lineage = ltrim($lineage, '@'); /* [2] */ + $lineageParts = explode('/', $lineage); /* [3] */ + $length = count($lineageParts); /* [4] */ + $patternType = $lineageParts[0]; /* [5] */ + + $patternName = $lineageParts[$length - 1]; /* [6] */ + $patternName = ltrim($patternName, '_'); /* [7] */ + $patternName = preg_replace('/^[0-9\-]+/', '', + $patternName); /* [8] */ + + $patternNameStripped = explode('.' . $patternExtension, $patternName); /* [9] */ + + if (count($patternNameStripped) > 1) { /* [10] */ + $patternName = $patternNameStripped[0]; + } + $lineage = $patternType . "-" . $patternName; /* [11] */ + } + if (PatternData::getOption($lineage)) { $patternLineages[] = array("lineagePattern" => $lineage, From 505f32c35fdd899b986504a9a1524e1351d24256 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Wed, 24 May 2017 11:06:27 -0700 Subject: [PATCH 406/436] updating composer to use Drupal Pattern Lab name --- composer.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 1deda66d..1d3339b3 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "pattern-lab/core", + "name": "drupal-pattern-lab/core", "description": "The core functionality for Pattern Lab.", "keywords": ["pattern lab", "styleguide", "style guide", "atomic", "atomic design"], - "homepage": "http://patternlab.io", + "homepage": "http://drupal-pattern-lab.github.io", "license": "MIT", "authors": [ { @@ -18,9 +18,8 @@ } ], "support": { - "issues": "https://github.com/pattern-lab/patternlab-php-core/issues", - "wiki": "http://patternlab.io/docs/", - "source": "https://github.com/pattern-lab/patternlab-php-core/releases" + "issues": "https://github.com/drupal-pattern-lab/patternlab-php-core/issues", + "source": "https://github.com/drupal-pattern-lab/patternlab-php-core/releases" }, "autoload": { "psr-0": { From 8a51a732714a8e4809e62b5deba5618c5f1e9087 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Wed, 24 May 2017 11:50:13 -0700 Subject: [PATCH 407/436] updating config path to use our vendor name --- src/PatternLab/Config.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index b07e90e3..a8ea4879 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -129,7 +129,8 @@ public static function init($baseDir = "", $verbose = true) { self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; - self::$plConfigPath = self::$options["baseDir"]."vendor/pattern-lab/core/".self::$plConfigPath; + // @todo Make folder name (i.e. `drupal-pattern-lab`) a variable + self::$plConfigPath = self::$options["baseDir"]."vendor/drupal-pattern-lab/core/".self::$plConfigPath; // can't add __DIR__ above so adding here if (!is_dir(self::$userConfigDir)) { From d45a33451359a48234482c80166300dc1f11a99d Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 25 May 2017 15:55:50 -0700 Subject: [PATCH 408/436] Revert "updating config path to use our vendor name" This reverts commit 8a51a732714a8e4809e62b5deba5618c5f1e9087. --- src/PatternLab/Config.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index a8ea4879..b07e90e3 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -129,8 +129,7 @@ public static function init($baseDir = "", $verbose = true) { self::$userConfigDirDash = self::$options["baseDir"].self::$userConfigDirDash; self::$userConfigDir = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean; self::$userConfigPath = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig; - // @todo Make folder name (i.e. `drupal-pattern-lab`) a variable - self::$plConfigPath = self::$options["baseDir"]."vendor/drupal-pattern-lab/core/".self::$plConfigPath; + self::$plConfigPath = self::$options["baseDir"]."vendor/pattern-lab/core/".self::$plConfigPath; // can't add __DIR__ above so adding here if (!is_dir(self::$userConfigDir)) { From b6c7409c0f331db0c3b89586a22426b99bcc5da4 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 25 May 2017 15:55:58 -0700 Subject: [PATCH 409/436] Revert "updating composer to use Drupal Pattern Lab name" This reverts commit 505f32c35fdd899b986504a9a1524e1351d24256. --- composer.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 1d3339b3..1deda66d 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "drupal-pattern-lab/core", + "name": "pattern-lab/core", "description": "The core functionality for Pattern Lab.", "keywords": ["pattern lab", "styleguide", "style guide", "atomic", "atomic design"], - "homepage": "http://drupal-pattern-lab.github.io", + "homepage": "http://patternlab.io", "license": "MIT", "authors": [ { @@ -18,8 +18,9 @@ } ], "support": { - "issues": "https://github.com/drupal-pattern-lab/patternlab-php-core/issues", - "source": "https://github.com/drupal-pattern-lab/patternlab-php-core/releases" + "issues": "https://github.com/pattern-lab/patternlab-php-core/issues", + "wiki": "http://patternlab.io/docs/", + "source": "https://github.com/pattern-lab/patternlab-php-core/releases" }, "autoload": { "psr-0": { From ad10d44905776fb161e5be31af5b8ed1189614e3 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 25 May 2017 16:12:39 -0700 Subject: [PATCH 410/436] updating info --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1deda66d..56458f0d 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,9 @@ } ], "support": { - "issues": "https://github.com/pattern-lab/patternlab-php-core/issues", + "issues": "https://github.com/drupal-pattern-lab/patternlab-php-core/issues", "wiki": "http://patternlab.io/docs/", - "source": "https://github.com/pattern-lab/patternlab-php-core/releases" + "source": "https://github.com/drupal-pattern-lab/patternlab-php-core/releases" }, "autoload": { "psr-0": { From 741ebb74c5aa19646a4e127514a22bca55cd2d71 Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Mon, 19 Jun 2017 15:08:21 +0300 Subject: [PATCH 411/436] Don't overwrite nameClean if it has already been set --- src/PatternLab/PatternData/Rules/PseudoPatternRule.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php index 426332e9..8575790c 100644 --- a/src/PatternLab/PatternData/Rules/PseudoPatternRule.php +++ b/src/PatternLab/PatternData/Rules/PseudoPatternRule.php @@ -171,7 +171,14 @@ public function run($depth, $ext, $path, $pathName, $name) { $patternStoreData["data"] = is_array($patternData) ? array_replace_recursive($patternDataBase, $patternData) : $patternDataBase; // if the pattern data store already exists make sure it is merged and overwrites this data - $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; + if (PatternData::checkOption($patternStoreKey)) { + $existingData = PatternData::getOption($patternStoreKey); + if (array_key_exists('nameClean', $existingData)) { + // don't overwrite nameClean + unset($patternStoreData['nameClean']); + } + $patternStoreData = array_replace_recursive($existingData, $patternStoreData); + } PatternData::setOption($patternStoreKey, $patternStoreData); } From 4ae8878d7e5d3fb68adc2168c661c7fd63a4d2bf Mon Sep 17 00:00:00 2001 From: Aleksi Peebles Date: Mon, 19 Jun 2017 19:54:13 +0300 Subject: [PATCH 412/436] Replace possible dots in pattern names with dashes --- src/PatternLab/PatternData/Rule.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PatternLab/PatternData/Rule.php b/src/PatternLab/PatternData/Rule.php index a7c3ab25..bbb500b4 100644 --- a/src/PatternLab/PatternData/Rule.php +++ b/src/PatternLab/PatternData/Rule.php @@ -104,6 +104,9 @@ protected function compareProp($name, $propCompare, $exact = false) { protected function getPatternName($pattern, $clean = true) { $patternBits = explode("-",$pattern,2); $patternName = (((int)$patternBits[0] != 0) || ($patternBits[0] == '00')) ? $patternBits[1] : $pattern; + // replace possible dots with dashes. pattern names cannot contain dots + // since they are used as id/class names in the styleguidekit. + $patternName = str_replace('.', '-', $patternName); return ($clean) ? (str_replace("-"," ",$patternName)) : $patternName; } From 60fc319c66c28ec086799fb1b47964e0ee6a6c01 Mon Sep 17 00:00:00 2001 From: Salem Ghoweri Date: Sat, 1 Jul 2017 19:21:20 -0400 Subject: [PATCH 413/436] Enabling the ability for Pattern Lab to follow any symlinks that may exist when scanning the pattern source directory for patterns; adds the RecursiveIteratorIterator flag to follow symbolic links while still continuing to skip dots (. and ..). This opens the door for some creative workarounds to the rigid way Pattern Lab expects pattern templates to be organized at the file system level + how the physical path to a pattern determines how it's organized in Pattern Lab... https://github.com/pattern-lab/patternlab-php-core/issues/28 --- src/PatternLab/PatternData.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 39129553..7980305c 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -116,15 +116,14 @@ public static function gather($options = array()) { if (!is_dir(Config::getOption("patternSourceDir"))) { Console::writeError("having patterns is important. please make sure you've installed a starterkit and/or that ".Console::getHumanReadablePath(Config::getOption("patternSourceDir"))." exists..."); } - $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(Config::getOption("patternSourceDir")), \RecursiveIteratorIterator::SELF_FIRST); - $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS); + + $patternSourceDir = Config::getOption("patternSourceDir"); + $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($patternSourceDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); // sort the returned objects $patternObjects = iterator_to_array($patternObjects); ksort($patternObjects); - $patternSourceDir = Config::getOption("patternSourceDir"); - foreach ($patternObjects as $name => $object) { $ext = $object->getExtension(); From b8af4a4b1fbe938e3c2bbf166e2d4fca91380da8 Mon Sep 17 00:00:00 2001 From: Salem Ghoweri Date: Sat, 26 Aug 2017 12:54:15 -0400 Subject: [PATCH 414/436] Working solution to automatically regenerate any Styleguidekit Assets Default files in the public dir if entire directory gets wiped. Solves https://github.com/drupal-pattern-lab/patternlab-php-core/issues/14 --- src/PatternLab/Builder.php | 225 ++++++++++++++++++++++--------------- 1 file changed, 133 insertions(+), 92 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index fb91068f..a7ac535d 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -29,77 +29,118 @@ use \Symfony\Component\Finder\Finder; class Builder { - + /** * When initializing the Builder class make sure the template helper is set-up */ public function __construct() { - + // set-up the pattern engine PatternEngine::init(); - + // set-up the various attributes for rendering templates Template::init(); - + } - + /** * Generates the annotations js file */ protected function generateAnnotations() { - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // note the start of the operation $dispatcherInstance->dispatch("builder.generateAnnotationsStart"); - + // default var $publicDir = Config::getOption("publicDir"); - + // encode the content so it can be written out $json = json_encode(Annotations::get()); - + // make sure annotations/ exists if (!is_dir($publicDir."/annotations")) { mkdir($publicDir."/annotations"); } - + // write out the new annotations.js file file_put_contents($publicDir."/annotations/annotations.js","var comments = ".$json.";"); - + // note the end of the operation $dispatcherInstance->dispatch("builder.generateAnnotationsEnd"); - + } - + /** * Generates the data that powers the index page */ protected function generateIndex() { - - // bomb if missing index.html + + /** + * Handle missing index.html. Solves https://github.com/drupal-pattern-lab/patternlab-php-core/issues/14 + * Could also be used to re-add missing styleguidekit assets with a few edits? + * + * 1. @TODO: What would be a better way to find our base vendor directory from here? + * 2. Locate the current theme's styleguidekit assets via the patternlab-styleguidekit `type` in composer.json + * 3. @TODO: Figure out a better way to future-proof path resolution for styleguidekit `dist` folder + * 4. Recusirively copy files from styleguidekit to publicDir via https://stackoverflow.com/a/7775949 + * 5. Make sure we only try to create new directories if they don't already exist + * 6. Only copy files if they are missing (vs changed, etc) + */ if (!file_exists(Config::getOption("publicDir")."/index.html")) { $index = Console::getHumanReadablePath(Config::getOption("publicDir")).DIRECTORY_SEPARATOR."index.html"; - Console::writeError("".$index." is missing. grab a copy from your StyleguideKit..."); + Console::writeWarning($index . " is missing. No biggie. Grabbing a copy from your StyleguideKit..."); + + $finder = new Finder(); + $base = __DIR__."/../../../"; /* [1] */ + $finder->files()->name("composer.json")->in($base)->contains('patternlab-styleguidekit')->sortByName(); /* [2] */ + + foreach ($finder as $file) { + $src = dirname($file->getRealPath()) . DIRECTORY_SEPARATOR . 'dist'; /* [3] */ + $dest= Config::getOption("publicDir"); + + if (is_dir($src)){ + + if(!is_dir($dest)) { + mkdir($dest, 0755); + } + + foreach ( /* [4] */ + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item + ) { + if ($item->isDir()) { + if(!is_dir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [5] */ + mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); + } + } else { + if(!file_exists($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [6] */ + copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); + } + } + } + } + } } - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // note the start of the operation $dispatcherInstance->dispatch("builder.generateIndexStart"); - + // default var $dataDir = Config::getOption("publicDir")."/styleguide/data"; - + // double-check that the data directory exists if (!is_dir($dataDir)) { FileUtil::makeDir($dataDir); } - + $output = ""; - + // load and write out the config options $config = array(); $exposedOptions = Config::getOption("exposedOptions"); @@ -107,7 +148,7 @@ protected function generateIndex() { $config[$exposedOption] = Config::getOption($exposedOption); } $output .= "var config = ".json_encode($config).";\n"; - + // load the ish Controls $ishControls = array(); $controlsToHide = array(); @@ -119,24 +160,24 @@ protected function generateIndex() { } $ishControls["ishControlsHide"] = $controlsToHide; $output .= "var ishControls = ".json_encode($ishControls).";\n"; - + // load and write out the items for the navigation $niExporter = new NavItemsExporter(); $navItems = $niExporter->run(); $output .= "var navItems = ".json_encode($navItems).";\n"; - + // load and write out the items for the pattern paths $patternPaths = array(); $ppdExporter = new PatternPathDestsExporter(); $patternPaths = $ppdExporter->run(); $output .= "var patternPaths = ".json_encode($patternPaths).";\n"; - + // load and write out the items for the view all paths $viewAllPaths = array(); $vapExporter = new ViewAllPathsExporter(); $viewAllPaths = $vapExporter->run($navItems); $output .= "var viewAllPaths = ".json_encode($viewAllPaths).";\n"; - + // gather plugin package information $packagesInfo = array(); $componentDir = Config::getOption("componentDir"); @@ -167,27 +208,27 @@ protected function generateIndex() { } } $output .= "var plugins = ".json_encode($packagesInfo).";"; - + // write out the data file_put_contents($dataDir."/patternlab-data.js",$output); - + // note the end of the operation $dispatcherInstance->dispatch("builder.generateIndexEnd"); - + } - + /** * Generates all of the patterns and puts them in the public directory * @param {Array} various options that might affect the export. primarily the location. */ protected function generatePatterns($options = array()) { - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // note the beginning of the operation $dispatcherInstance->dispatch("builder.generatePatternsStart"); - + // set-up common vars $exportFiles = (isset($options["exportFiles"]) && $options["exportFiles"]); $exportDir = Config::getOption("exportDir"); @@ -197,66 +238,66 @@ protected function generatePatterns($options = array()) { $suffixRendered = Config::getOption("outputFileSuffixes.rendered"); $suffixRaw = Config::getOption("outputFileSuffixes.rawTemplate"); $suffixMarkupOnly = Config::getOption("outputFileSuffixes.markupOnly"); - + // make sure the export dir exists if ($exportFiles && !is_dir($exportDir)) { mkdir($exportDir); } - + // make sure patterns exists if (!is_dir($patternPublicDir)) { mkdir($patternPublicDir); } - + // loop over the pattern data store to render the individual patterns $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - + if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"])) { - + $path = $patternStoreData["pathDash"]; $pathName = (isset($patternStoreData["pseudo"])) ? $patternStoreData["pathOrig"] : $patternStoreData["pathName"]; - + // modify the pattern mark-up $markup = $patternStoreData["code"]; $markupFull = $patternStoreData["header"].$markup.$patternStoreData["footer"]; $markupEngine = file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension); - + // if the pattern directory doesn't exist create it if (!is_dir($patternPublicDir."/".$path)) { mkdir($patternPublicDir."/".$path); } - + // write out the various pattern files file_put_contents($patternPublicDir."/".$path."/".$path.$suffixRendered.".html",$markupFull); if (!$exportFiles) { file_put_contents($patternPublicDir."/".$path."/".$path.$suffixMarkupOnly.".html",$markup); file_put_contents($patternPublicDir."/".$path."/".$path.$suffixRaw.".".$patternExtension,$markupEngine); } - + } - + } - + // note the end of the operation $dispatcherInstance->dispatch("builder.generatePatternsEnd"); - + } - + /** * Generates the style guide view */ protected function generateStyleguide() { - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // note the beginning of the operation $dispatcherInstance->dispatch("builder.generateStyleguideStart"); - + // default var $publicDir = Config::getOption("publicDir"); - + // load the pattern loader $ppdExporter = new PatternPathSrcExporter(); $patternPathSrc = $ppdExporter->run(); @@ -265,56 +306,56 @@ protected function generateStyleguide() { $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; $patternLoader = new $patternLoaderClass($options); - + // check directories i need if (!is_dir($publicDir."/styleguide/")) { mkdir($publicDir."/styleguide/"); } - + if (!is_dir($publicDir."/styleguide/html/")) { mkdir($publicDir."/styleguide/html/"); } - + // grab the partials into a data object for the style guide $ppExporter = new PatternPartialsExporter(); $partials = $ppExporter->run(); - + // add the pattern data so it can be exported $patternData = array(); - + // add the pattern lab specific mark-up $filesystemLoader = Template::getFilesystemLoader(); $stringLoader = Template::getStringLoader(); - + $globalData = Data::get(); $globalData["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); $globalData["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); $globalData["viewall"] = true; - + $header = $patternLoader->render(array("pattern" => Template::getPatternHead(), "data" => $globalData)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $patternLoader->render(array("pattern" => Template::getPatternFoot(), "data" => $globalData)); - + $styleGuidePage = $header.$code.$footer; - + file_put_contents($publicDir."/styleguide/html/styleguide.html",$styleGuidePage); - + // note the end of the operation $dispatcherInstance->dispatch("builder.generateStyleguideEnd"); - + } - + /** * Generates the view all pages */ protected function generateViewAllPages() { - + // set-up the dispatcher $dispatcherInstance = Dispatcher::getInstance(); - + // note the beginning of the operation $dispatcherInstance->dispatch("builder.generateViewAllPagesStart"); - + // default vars $patternPublicDir = Config::getOption("patternPublicDir"); $htmlHead = Template::getHTMLHead(); @@ -324,7 +365,7 @@ protected function generateViewAllPages() { $filesystemLoader = Template::getFilesystemLoader(); $stringLoader = Template::getStringLoader(); $globalData = Data::get(); - + // load the pattern loader $ppdExporter = new PatternPathSrcExporter(); $patternPathSrc = $ppdExporter->run(); @@ -333,40 +374,40 @@ protected function generateViewAllPages() { $patternEngineBasePath = PatternEngine::getInstance()->getBasePath(); $patternLoaderClass = $patternEngineBasePath."\Loaders\PatternLoader"; $patternLoader = new $patternLoaderClass($options); - + // make sure view all is set $globalData["viewall"] = true; - + // make sure the pattern dir exists if (!is_dir($patternPublicDir)) { mkdir($patternPublicDir); } - + // add view all to each list $store = PatternData::get(); foreach ($store as $patternStoreKey => $patternStoreData) { - + if ($patternStoreData["category"] == "patternSubtype") { - + // grab the partials into a data object for the style guide $ppExporter = new PatternPartialsExporter(); $partials = $ppExporter->run($patternStoreData["type"],$patternStoreData["name"]); - + if (!empty($partials["partials"])) { - + // add the pattern data so it can be exported $patternData = array(); $patternData["patternPartial"] = "viewall-".$patternStoreData["typeDash"]."-".$patternStoreData["nameDash"]; - + $globalData["patternLabHead"] = $stringLoader->render(array("string" => Template::getHTMLHead(), "data" => array("cacheBuster" => $partials["cacheBuster"]))); $globalData["patternLabFoot"] = $stringLoader->render(array("string" => Template::getHTMLFoot(), "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); - + // render the parts and join them $header = $patternLoader->render(array("pattern" => $patternHead, "data" => $globalData)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $patternLoader->render(array("pattern" => $patternFoot, "data" => $globalData)); $viewAllPage = $header.$code.$footer; - + // if the pattern directory doesn't exist create it $patternPath = $patternStoreData["pathDash"]; if (!is_dir($patternPublicDir."/".$patternPath)) { @@ -375,31 +416,31 @@ protected function generateViewAllPages() { } else { file_put_contents($patternPublicDir."/".$patternPath."/index.html",$viewAllPage); } - + } - + } else if (($patternStoreData["category"] == "patternType") && PatternData::hasPatternSubtype($patternStoreData["nameDash"])) { - + // grab the partials into a data object for the style guide $ppExporter = new PatternPartialsExporter(); $partials = $ppExporter->run($patternStoreData["name"]); - + if (!empty($partials["partials"])) { - + // add the pattern data so it can be exported $patternData = array(); $patternData["patternPartial"] = "viewall-".$patternStoreData["nameDash"]."-all"; - + // add the pattern lab specific mark-up $globalData["patternLabHead"] = $stringLoader->render(array("string" => $htmlHead, "data" => array("cacheBuster" => $partials["cacheBuster"]))); $globalData["patternLabFoot"] = $stringLoader->render(array("string" => $htmlFoot, "data" => array("cacheBuster" => $partials["cacheBuster"], "patternData" => json_encode($patternData)))); - + // render the parts and join them $header = $patternLoader->render(array("pattern" => $patternHead, "data" => $globalData)); $code = $filesystemLoader->render(array("template" => "viewall", "data" => $partials)); $footer = $patternLoader->render(array("pattern" => $patternFoot, "data" => $globalData)); $viewAllPage = $header.$code.$footer; - + // if the pattern directory doesn't exist create it $patternPath = $patternStoreData["pathDash"]; if (!is_dir($patternPublicDir."/".$patternPath)) { @@ -408,16 +449,16 @@ protected function generateViewAllPages() { } else { file_put_contents($patternPublicDir."/".$patternPath."/index.html",$viewAllPage); } - + } - + } - + } - + // note the end of the operation $dispatcherInstance->dispatch("builder.generateViewAllPagesEnd"); - + } - + } From 0eace9ea6b2926c1126d1437b923298225851f27 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 28 Aug 2017 11:33:00 -0700 Subject: [PATCH 415/436] adding styleguidekit path var --- src/PatternLab/Builder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index a7ac535d..39034273 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -95,6 +95,7 @@ protected function generateIndex() { $finder = new Finder(); $base = __DIR__."/../../../"; /* [1] */ + $kit_path = Config::getOption("styleguideKitPath"); $finder->files()->name("composer.json")->in($base)->contains('patternlab-styleguidekit')->sortByName(); /* [2] */ foreach ($finder as $file) { From b16f3f6f7b0a6b0da7ec04d7ca28e091f43c11fa Mon Sep 17 00:00:00 2001 From: Salem Ghoweri Date: Sat, 2 Sep 2017 18:51:22 -0400 Subject: [PATCH 416/436] fix: cleaning up base path directory logic to make a little less prone to breaking --- src/PatternLab/Builder.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index 39034273..bceb8147 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -82,24 +82,23 @@ protected function generateIndex() { * Handle missing index.html. Solves https://github.com/drupal-pattern-lab/patternlab-php-core/issues/14 * Could also be used to re-add missing styleguidekit assets with a few edits? * - * 1. @TODO: What would be a better way to find our base vendor directory from here? - * 2. Locate the current theme's styleguidekit assets via the patternlab-styleguidekit `type` in composer.json - * 3. @TODO: Figure out a better way to future-proof path resolution for styleguidekit `dist` folder - * 4. Recusirively copy files from styleguidekit to publicDir via https://stackoverflow.com/a/7775949 - * 5. Make sure we only try to create new directories if they don't already exist - * 6. Only copy files if they are missing (vs changed, etc) + * 1. @TODO: Figure out a better way to future-proof path resolution for styleguidekit `dist` folder + * 2. Recusirively copy files from styleguidekit to publicDir via https://stackoverflow.com/a/7775949 + * 3. Make sure we only try to create new directories if they don't already exist + * 4. Only copy files if they are missing (vs changed, etc) */ if (!file_exists(Config::getOption("publicDir")."/index.html")) { $index = Console::getHumanReadablePath(Config::getOption("publicDir")).DIRECTORY_SEPARATOR."index.html"; - Console::writeWarning($index . " is missing. No biggie. Grabbing a copy from your StyleguideKit..."); + Console::writeWarning($index . " is missing. No biggie. Grabbing a fresh copy from your StyleguideKit..."); + $baseDir = Config::getOption("baseDir") . '/vendor'; $finder = new Finder(); - $base = __DIR__."/../../../"; /* [1] */ - $kit_path = Config::getOption("styleguideKitPath"); - $finder->files()->name("composer.json")->in($base)->contains('patternlab-styleguidekit')->sortByName(); /* [2] */ + + // Locate the current theme's styleguidekit assets via the patternlab-styleguidekit `type` in composer.json + $finder->files()->name("composer.json")->in($baseDir)->contains('patternlab-styleguidekit')->sortByName(); foreach ($finder as $file) { - $src = dirname($file->getRealPath()) . DIRECTORY_SEPARATOR . 'dist'; /* [3] */ + $src = dirname($file->getRealPath()) . DIRECTORY_SEPARATOR . 'dist'; /* [1] */ $dest= Config::getOption("publicDir"); if (is_dir($src)){ @@ -108,16 +107,16 @@ protected function generateIndex() { mkdir($dest, 0755); } - foreach ( /* [4] */ + foreach ( /* [2] */ $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item ) { if ($item->isDir()) { - if(!is_dir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [5] */ + if(!is_dir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [3] */ mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); } } else { - if(!file_exists($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [6] */ + if(!file_exists($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [4] */ copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); } } From 30ab3d0e7278bdd8500ee732d4d26ec908028f5e Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Sun, 3 Sep 2017 11:24:46 -0700 Subject: [PATCH 417/436] Cleanup packages badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e49258e8..a7c88949 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![license](https://img.shields.io/github/license/pattern-lab/patternlab-php-core.svg) -[![Packagist](https://img.shields.io/packagist/v/pattern-lab/core.svg)](https://packagist.org/packages/pattern-lab/core) [![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg)](https://gitter.im/pattern-lab/php) +[![Gitter](https://img.shields.io/gitter/room/pattern-lab/php.svg)](https://gitter.im/pattern-lab/php) # Pattern Lab Core From e38ee4d16868543b405ff99a719f4b5295fa2c3d Mon Sep 17 00:00:00 2001 From: Salem Date: Sat, 7 Oct 2017 15:25:45 -0400 Subject: [PATCH 418/436] Removing references to drupal-pattern-lab Chore as part of mega merge back into the main PL mothership repo --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 56458f0d..1deda66d 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,9 @@ } ], "support": { - "issues": "https://github.com/drupal-pattern-lab/patternlab-php-core/issues", + "issues": "https://github.com/pattern-lab/patternlab-php-core/issues", "wiki": "http://patternlab.io/docs/", - "source": "https://github.com/drupal-pattern-lab/patternlab-php-core/releases" + "source": "https://github.com/pattern-lab/patternlab-php-core/releases" }, "autoload": { "psr-0": { From 5ebbfc5e4c89d72d7e051f65f817af542a6eddd9 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 9 Oct 2017 11:28:02 -0700 Subject: [PATCH 419/436] Adding the new PHP crew --- composer.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1deda66d..56b50237 100644 --- a/composer.json +++ b/composer.json @@ -5,11 +5,21 @@ "homepage": "http://patternlab.io", "license": "MIT", "authors": [ + { + "name": "Evan Lovely", + "homepage": "http://evanlovely.com", + "role": "Lead Developer" + }, + { + "name": "Salem Ghoweri", + "homepage": "https://github.com/sghoweri", + "role": "Developer" + }, { "name": "Dave Olsen", "email": "dmolsen@gmail.com", "homepage": "http://dmolsen.com", - "role": "Lead Developer" + "role": "Former Lead Developer" }, { "name": "Brad Frost", From 8caaab644d9f13b858c3819e7ea8b639283fe643 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 9 Oct 2017 11:29:39 -0700 Subject: [PATCH 420/436] indents --- composer.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 56b50237..527ae1db 100644 --- a/composer.json +++ b/composer.json @@ -5,16 +5,16 @@ "homepage": "http://patternlab.io", "license": "MIT", "authors": [ - { - "name": "Evan Lovely", - "homepage": "http://evanlovely.com", - "role": "Lead Developer" - }, - { - "name": "Salem Ghoweri", - "homepage": "https://github.com/sghoweri", - "role": "Developer" - }, + { + "name": "Evan Lovely", + "homepage": "http://evanlovely.com", + "role": "Lead Developer" + }, + { + "name": "Salem Ghoweri", + "homepage": "https://github.com/sghoweri", + "role": "Developer" + }, { "name": "Dave Olsen", "email": "dmolsen@gmail.com", From 3a825657449a14d3fd72122399ae430fb970d024 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 9 Oct 2017 14:28:59 -0700 Subject: [PATCH 421/436] Adding support for ishViewportRange (#131) * Adding support for ishViewportRange * adding ishViewportRang default settings --- config/config.yml.default | 6 ++++++ src/PatternLab/Config.php | 1 + 2 files changed, 7 insertions(+) diff --git a/config/config.yml.default b/config/config.yml.default index 5b9c5a96..e8777e92 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -43,3 +43,9 @@ defaultPattern: "all" # show pattern info by default on the "view all" views defaultShowPatternInfo: false + +# Set a range of viewport widths for S, M, & L buttons +ishViewportRange: + s: [320, 500] + m: [500, 800] + l: [800, 1200] diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index b07e90e3..ee23cd92 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -245,6 +245,7 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("ishFontSize"); self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); + self::setExposedOption("ishViewportRange"); self::setExposedOption("outputFileSuffixes"); self::setExposedOption("plugins"); From 8f66d4feca9a97a79cacb24e3cb8ba7cafeddfcd Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Tue, 10 Oct 2017 12:32:43 -0700 Subject: [PATCH 422/436] Locking collections dependency down to 1.4 as zippy had dependened on it and when it went to 1.5.0 it required php 7.1 + (#133) --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 527ae1db..da40fa12 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "require": { "php": ">=5.4", "alchemy/zippy": "^0.3", + "doctrine/collections": "1.4.0", "kevinlebrun/colors.php": "^1.0", "michelf/php-markdown": "^1.6", "seld/jsonlint": "^1.0", From 064a0502a717f91a434043e337d0c77c21402c4f Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Tue, 10 Oct 2017 14:48:56 -0700 Subject: [PATCH 423/436] Allowing Pattern State to be set in MD files front matter. Just like node versions. (#134) --- src/PatternLab/PatternData/Rules/DocumentationRule.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index 4e9ef3fa..e38499f8 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -83,7 +83,11 @@ public function run($depth, $ext, $path, $pathName, $name) { if (isset($title)) { $patternStoreData["nameClean"] = $title; } - + + if (isset($yaml["state"])) { + $patternStoreData["state"] = $yaml["state"]; + } + // if the pattern data store already exists make sure this data overwrites it $patternStoreData = (PatternData::checkOption($patternStoreKey)) ? array_replace_recursive(PatternData::getOption($patternStoreKey),$patternStoreData) : $patternStoreData; PatternData::setOption($patternStoreKey, $patternStoreData); From d703ad214e1ff2fa0ff6de41b32d9df17a30db35 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 12 Oct 2017 15:04:09 -0700 Subject: [PATCH 424/436] Fix for Styleguidekit v4 --- src/PatternLab/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index ee23cd92..73ecc09d 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -242,6 +242,7 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("cacheBuster"); self::setExposedOption("defaultPattern"); self::setExposedOption("defaultShowPatternInfo"); + self::setExposedOption("patternExtension"); self::setExposedOption("ishFontSize"); self::setExposedOption("ishMaximum"); self::setExposedOption("ishMinimum"); From 69c547152cb8ab9557eddae42e8532ec2e6139dd Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 12 Oct 2017 15:34:19 -0700 Subject: [PATCH 425/436] Adding to MD docs Yaml meta settings: hidden, noviewall that work. Adding for future use: order, tags, links. (#137) --- .../PatternData/Rules/DocumentationRule.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Rules/DocumentationRule.php b/src/PatternLab/PatternData/Rules/DocumentationRule.php index e38499f8..528925fb 100644 --- a/src/PatternLab/PatternData/Rules/DocumentationRule.php +++ b/src/PatternLab/PatternData/Rules/DocumentationRule.php @@ -80,12 +80,24 @@ public function run($depth, $ext, $path, $pathName, $name) { "meta" => $yaml, "full" => $doc); + // can set `title: My Cool Pattern` instead of lifting from file name if (isset($title)) { $patternStoreData["nameClean"] = $title; } - if (isset($yaml["state"])) { - $patternStoreData["state"] = $yaml["state"]; + $availableKeys = [ + 'state', // can use `state: inprogress` instead of `button@inprogress.mustache` + 'hidden', // setting to `true`, removes from menu and viewall, which is same as adding `_` prefix + 'noviewall', // setting to `true`, removes from view alls but keeps in menu, which is same as adding `-` prefix + 'order', // @todo implement order + 'tags', // not implemented, awaiting spec approval and integration with styleguide kit. adding to be in sync with Node version. + 'links', // not implemented, awaiting spec approval and integration with styleguide kit. adding to be in sync with Node version. + ]; + + foreach ($availableKeys as $key) { + if (isset($yaml[$key])) { + $patternStoreData[$key] = $yaml[$key]; + } } // if the pattern data store already exists make sure this data overwrites it From 14cb25f664a96f98b2e4354344fbbf0f727a9348 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 12 Oct 2017 16:07:06 -0700 Subject: [PATCH 426/436] Preventing state from being added to Patterns in lineage. (#139) --- src/PatternLab/PatternData.php | 15 +++++++++------ .../PatternData/Helpers/PatternStateHelper.php | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 7980305c..1bbd0116 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -180,17 +180,20 @@ public static function gather($options = array()) { $event = new PatternDataEvent($options); $dispatcherInstance->dispatch("patternData.lineageHelperEnd",$event); + + // `PatternStateHelper` is deprecated. It was for adding state to all patterns in the lineage of the pattern with state and that is no longer needed. Commenting out use and deprecating class in case there's a use I haven't figured out. + // dispatch that the pattern state helper is about to start - $event = new PatternDataEvent($options); - $dispatcherInstance->dispatch("patternData.patternStateHelperStart",$event); +// $event = new PatternDataEvent($options); +// $dispatcherInstance->dispatch("patternData.patternStateHelperStart",$event); // using the lineage info update the pattern states on PatternData::$store - $patternStateHelper = new PatternStateHelper(); - $patternStateHelper->run(); +// $patternStateHelper = new PatternStateHelper(); +// $patternStateHelper->run(); // dispatch that the pattern state helper is ended - $event = new PatternDataEvent($options); - $dispatcherInstance->dispatch("patternData.patternStateHelperEnd",$event); +// $event = new PatternDataEvent($options); +// $dispatcherInstance->dispatch("patternData.patternStateHelperEnd",$event); // set-up code pattern paths $ppdExporter = new PatternPathSrcExporter(); diff --git a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php index e8fd2b5c..abe4a665 100644 --- a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php @@ -17,6 +17,11 @@ use \PatternLab\PatternData; use \PatternLab\Timer; +/** + * Class PatternStateHelper + * @package PatternLab\PatternData\Helpers + * @deprecated 3.0.0 It was for adding state to all patterns in the lineage of the pattern with state and that is no longer needed. + */ class PatternStateHelper extends \PatternLab\PatternData\Helper { public function __construct($options = array()) { From 75914bd5e97fe1c4b6d0d9c611692d8a64c85c21 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Fri, 13 Oct 2017 09:34:48 -0700 Subject: [PATCH 427/436] Improving pattern linking to include View Alls of patternType and patternSubtype (#140) --- .../Exporters/DataLinkExporter.php | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php index fdd875eb..9494cd8d 100644 --- a/src/PatternLab/PatternData/Exporters/DataLinkExporter.php +++ b/src/PatternLab/PatternData/Exporters/DataLinkExporter.php @@ -31,16 +31,33 @@ public function __construct($options = array()) { public function run() { foreach ($this->store as $patternStoreKey => $patternStoreData) { - - if ($patternStoreData["category"] == "pattern") { - - if (isset($patternStoreData["pathDash"])) { - $value = "../../patterns/".$patternStoreData["pathDash"]."/".$patternStoreData["pathDash"].".html"; - Data::setOptionLink($patternStoreKey, $value); - } - - } - + + switch ($patternStoreData["category"]) { + // atoms - view all + case "patternType": + if (isset($patternStoreData["pathDash"])) { + $value = "../../patterns/" . $patternStoreData["pathDash"] . "/index.html"; + Data::setOptionLink("viewall-" . $patternStoreData["nameDash"] . "-all", $value); + } + break; + + // atoms/forms - view all + case "patternSubtype": + if (isset($patternStoreData["pathDash"])) { + $value = "../../patterns/" . $patternStoreData["pathDash"] . "/index.html"; + Data::setOptionLink($patternStoreData["partial"], $value); + } + break; + + // atoms/forms/select.mustache + case "pattern": + if (isset($patternStoreData["pathDash"])) { + $value = "../../patterns/" . $patternStoreData["pathDash"] . "/" . $patternStoreData["pathDash"] . ".html"; + Data::setOptionLink($patternStoreKey, $value); + } + break; + } + } } From 29f55cc6767697ec730d07eb45b3bc49cba25349 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Fri, 13 Oct 2017 12:59:11 -0700 Subject: [PATCH 428/436] Implementing Pattern Type (ie atoms) Documentation (#141) * Implementing Pattern Type (ie atoms) Documentation * Enabling patternType docs in "All" as well --- .../Exporters/PatternPartialsExporter.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index 14d7ab08..c36a75c5 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -101,8 +101,25 @@ public function run($type = "", $subtype = "") { $patternPartials[] = $patternPartialData; } - - } + + } else if (($patternStoreData["category"] == "pattern") && (isset($patternStoreData["full"]) && ($type === $patternStoreData["full"] || $type === ""))) { + // This is for `patternType` docs. Given this structure: + // - _patterns/ + // - atoms/ + // - forms/ + // - atoms.md + // This will take the contents of `atoms.md` and place at top of "Atoms > View All" + + $patternPartialData = array(); + // Getting the name from md's `title: My Name` works here, as does the link, but it doesn't make sense to link to the view you are already on. Plus you can just do the title in the MD doc. Keeping here for now in case it's wanted later. + // $patternPartialData["patternName"] = isset($patternStoreData["nameClean"]) ? $patternStoreData["nameClean"] : ''; + // $patternPartialData["patternLink"] = $patternStoreData["full"] . "/index.html"; + + $patternPartialData["patternSectionSubtype"] = true; + $patternPartialData["patternDesc"] = isset($patternStoreData["desc"]) ? $patternStoreData["desc"] : ""; + + $patternPartials[] = $patternPartialData; + } } From 05da5300843eac0ad5ae66ca50df69b8aed7e7e8 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Fri, 13 Oct 2017 14:28:32 -0700 Subject: [PATCH 429/436] Bugfix for hidden patterns with docs --- .../PatternData/Exporters/PatternPartialsExporter.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index c36a75c5..f5d8e1e4 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -47,8 +47,10 @@ public function run($type = "", $subtype = "") { $suffixRendered = Config::getOption("outputFileSuffixes.rendered"); foreach ($this->store as $patternStoreKey => $patternStoreData) { - - if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) { + + $canShow = isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]); + + if (($patternStoreData["category"] == "pattern") && $canShow && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) { if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) { @@ -102,7 +104,7 @@ public function run($type = "", $subtype = "") { } - } else if (($patternStoreData["category"] == "pattern") && (isset($patternStoreData["full"]) && ($type === $patternStoreData["full"] || $type === ""))) { + } else if (($patternStoreData["category"] == "pattern") && $canShow &&(isset($patternStoreData["full"]) && ($type === $patternStoreData["full"] || $type === ""))) { // This is for `patternType` docs. Given this structure: // - _patterns/ // - atoms/ From ca457f52d14dc698dfe4436e030cf74f2f1e03d7 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Fri, 13 Oct 2017 15:18:11 -0700 Subject: [PATCH 430/436] Fix for patternType docs --- .../Exporters/PatternPartialsExporter.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index f5d8e1e4..b3ab81a7 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -48,6 +48,16 @@ public function run($type = "", $subtype = "") { foreach ($this->store as $patternStoreKey => $patternStoreData) { + // Docs for patternTypes (i.e. `atoms.md`), don't have these rules and need them to pass below conditionals + if ( + !isset($patternStoreData['depth']) + && !isset($patternStoreData['hidden']) + && !isset($patternStoreData['noviewall']) + ) { + $patternStoreData["hidden"] = false; + $patternStoreData["noviewall"] = false; + $patternStoreData["depth"] = 0; + } $canShow = isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]); if (($patternStoreData["category"] == "pattern") && $canShow && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) { @@ -104,7 +114,7 @@ public function run($type = "", $subtype = "") { } - } else if (($patternStoreData["category"] == "pattern") && $canShow &&(isset($patternStoreData["full"]) && ($type === $patternStoreData["full"] || $type === ""))) { + } else if (($patternStoreData["category"] == "pattern") && $canShow && (isset($patternStoreData["full"]) && ($type === $patternStoreData["full"] || $type === ""))) { // This is for `patternType` docs. Given this structure: // - _patterns/ // - atoms/ From edcbeb16d16ddbac5a52299ca821d1b058c76247 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 16 Oct 2017 10:31:19 -0700 Subject: [PATCH 431/436] Bugfix for patternType docs - Atoms docs were showing in Atoms/Forms View All --- .../PatternData/Exporters/PatternPartialsExporter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php index b3ab81a7..cf441746 100644 --- a/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php +++ b/src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php @@ -114,7 +114,13 @@ public function run($type = "", $subtype = "") { } - } else if (($patternStoreData["category"] == "pattern") && $canShow && (isset($patternStoreData["full"]) && ($type === $patternStoreData["full"] || $type === ""))) { + } else if ( + ($patternStoreData["category"] == "pattern") + && $canShow + && (isset($patternStoreData["full"]) + && ($type === $patternStoreData["full"] || $type === "")) + && ($subtype === "") + ) { // This is for `patternType` docs. Given this structure: // - _patterns/ // - atoms/ From 495d9c8ca9ee1cac0f14df1b79f922fb991714a8 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 16 Oct 2017 10:45:31 -0700 Subject: [PATCH 432/436] bringing back state via lineage (#142) bringing back state via lineage --- src/PatternLab/PatternData.php | 20 ++++++++++--------- .../Helpers/PatternStateHelper.php | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/PatternLab/PatternData.php b/src/PatternLab/PatternData.php index 1bbd0116..3e7ced4e 100644 --- a/src/PatternLab/PatternData.php +++ b/src/PatternLab/PatternData.php @@ -124,7 +124,11 @@ public static function gather($options = array()) { $patternObjects = iterator_to_array($patternObjects); ksort($patternObjects); - foreach ($patternObjects as $name => $object) { + /** + * @var string $name + * @var \SplFileInfo $object + */ + foreach ($patternObjects as $name => $object) { $ext = $object->getExtension(); $isDir = $object->isDir(); @@ -181,19 +185,17 @@ public static function gather($options = array()) { $dispatcherInstance->dispatch("patternData.lineageHelperEnd",$event); - // `PatternStateHelper` is deprecated. It was for adding state to all patterns in the lineage of the pattern with state and that is no longer needed. Commenting out use and deprecating class in case there's a use I haven't figured out. - // dispatch that the pattern state helper is about to start -// $event = new PatternDataEvent($options); -// $dispatcherInstance->dispatch("patternData.patternStateHelperStart",$event); + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.patternStateHelperStart",$event); // using the lineage info update the pattern states on PatternData::$store -// $patternStateHelper = new PatternStateHelper(); -// $patternStateHelper->run(); + $patternStateHelper = new PatternStateHelper(); + $patternStateHelper->run(); // dispatch that the pattern state helper is ended -// $event = new PatternDataEvent($options); -// $dispatcherInstance->dispatch("patternData.patternStateHelperEnd",$event); + $event = new PatternDataEvent($options); + $dispatcherInstance->dispatch("patternData.patternStateHelperEnd",$event); // set-up code pattern paths $ppdExporter = new PatternPathSrcExporter(); diff --git a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php index abe4a665..817b61c0 100644 --- a/src/PatternLab/PatternData/Helpers/PatternStateHelper.php +++ b/src/PatternLab/PatternData/Helpers/PatternStateHelper.php @@ -20,7 +20,6 @@ /** * Class PatternStateHelper * @package PatternLab\PatternData\Helpers - * @deprecated 3.0.0 It was for adding state to all patterns in the lineage of the pattern with state and that is no longer needed. */ class PatternStateHelper extends \PatternLab\PatternData\Helper { From b654e826d3aa32aa71f670543c21ca169e357d9a Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 19 Oct 2017 14:03:35 -0700 Subject: [PATCH 433/436] Exposing `theme` and `patternStates` to Styleguidekit (#143) --- src/PatternLab/Config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PatternLab/Config.php b/src/PatternLab/Config.php index 73ecc09d..c090348f 100644 --- a/src/PatternLab/Config.php +++ b/src/PatternLab/Config.php @@ -248,6 +248,8 @@ public static function init($baseDir = "", $verbose = true) { self::setExposedOption("ishMinimum"); self::setExposedOption("ishViewportRange"); self::setExposedOption("outputFileSuffixes"); + self::setExposedOption("patternStates"); + self::setExposedOption("theme"); self::setExposedOption("plugins"); } From ac0e1380ace170ad774cde70cd0730bbe2935706 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Thu, 26 Oct 2017 10:39:40 -0700 Subject: [PATCH 434/436] Removing defaults for ishViewportRange so it doesn't unexpectedly limit viewport range. (#145) --- config/config.yml.default | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/config.yml.default b/config/config.yml.default index e8777e92..5b9c5a96 100644 --- a/config/config.yml.default +++ b/config/config.yml.default @@ -43,9 +43,3 @@ defaultPattern: "all" # show pattern info by default on the "view all" views defaultShowPatternInfo: false - -# Set a range of viewport widths for S, M, & L buttons -ishViewportRange: - s: [320, 500] - m: [500, 800] - l: [800, 1200] From 46ae845673396ec67b24075d1ee66ac6ac10112d Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Wed, 8 Nov 2017 15:56:57 -0800 Subject: [PATCH 435/436] Disabling unhelpful console warning. --- src/PatternLab/PatternData/Helpers/LineageHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PatternLab/PatternData/Helpers/LineageHelper.php b/src/PatternLab/PatternData/Helpers/LineageHelper.php index 1d5676e5..a96c9db1 100644 --- a/src/PatternLab/PatternData/Helpers/LineageHelper.php +++ b/src/PatternLab/PatternData/Helpers/LineageHelper.php @@ -107,7 +107,8 @@ public function run() { if (strpos($lineage, '/') === false) { $fileName = $patternStoreData["pathName"].".".$patternExtension; - Console::writeWarning("you may have a typo in ".$fileName.". `".$lineage."` is not a valid pattern..."); + // This doesn't work very consistently. @todo Improve error reporting when trying to include a Twig file that doesn't exist (b/c doing so simply outputs the path to the file you were trying to include, giving no error to user that include path had a typo) + // Console::writeWarning("you may have a typo in ".$fileName.". `".$lineage."` is not a valid pattern..."); } } From 009399c5cb175f1d5a1fafc7b07abc1f2d13a0a3 Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Tue, 27 Feb 2018 14:12:27 -0800 Subject: [PATCH 436/436] Structuring all the same data that went into `patternlab-data.js` and putting it into `patternlab-data.json` too (#161) --- src/PatternLab/Builder.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index bceb8147..104fe9a6 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -211,6 +211,16 @@ protected function generateIndex() { // write out the data file_put_contents($dataDir."/patternlab-data.js",$output); + // Structuring all the same data that went into `patternlab-data.js` and putting it into `patternlab-data.json` too + $allPlData = array( + 'config' => $config, + 'ishControls' => $ishControls, + 'navItems' => $navItems, + 'patternPaths' => $patternPaths, + 'viewAllPaths' => $viewAllPaths, + 'plugins' => $packagesInfo, + ); + file_put_contents($dataDir."/patternlab-data.json", json_encode($allPlData)); // note the end of the operation $dispatcherInstance->dispatch("builder.generateIndexEnd");