From b5769cc6673a91ce029d146e4aa169594af830ce Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Mon, 11 Jul 2016 23:01:40 -0400 Subject: [PATCH] laying in Pattern Lab 2 --- .gitignore | 8 +- LICENSE | 2 +- composer.json | 66 ++++++++++++ config/{README => .gitkeep} | 0 core/console | 46 +++++++++ core/server/router.php | 41 ++++++++ core/src/PatternLab/Installer.php | 162 ++++++++++++++++++++++++++++++ public/README | 3 - source/{README => .gitkeep} | 0 9 files changed, 319 insertions(+), 9 deletions(-) create mode 100644 composer.json rename config/{README => .gitkeep} (100%) create mode 100644 core/console create mode 100644 core/server/router.php create mode 100644 core/src/PatternLab/Installer.php delete mode 100644 public/README rename source/{README => .gitkeep} (100%) diff --git a/.gitignore b/.gitignore index cfc3838..d4f687c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ .DS_Store +export/* public/* -source/* -config.ini -latest-change.txt -*-ck.js -*.sass-cache/ \ No newline at end of file +source/styleguide/* +vendor/* diff --git a/LICENSE b/LICENSE index 465444e..1190640 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-14 Brad Frost, http://bradfrostweb.com & Dave Olsen, http://dmolsen.com +Copyright (c) 2016 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 diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d0049e0 --- /dev/null +++ b/composer.json @@ -0,0 +1,66 @@ +{ + "name": "pattern-lab/edition-mustache-standard", + "description": "The Standard Edition of Pattern Lab for Mustache. Installs all Mustache-related dependencies.", + "keywords": ["pattern lab", "mustache"], + "homepage": "http://patternlab.io", + "license": "MIT", + "type": "project", + "authors": [ + { + "name": "Dave Olsen", + "email": "dmolsen@gmail.com", + "homepage": "http://dmolsen.com", + "role": "Lead Developer" + } + ], + "support": { + "issues": "https://github.com/pattern-lab/patternlab-php/issues", + "wiki": "http://patternlab.io/docs/", + "source": "https://github.com/pattern-lab/patternlab-php/releases" + }, + "autoload": { + "psr-0": { + "PatternLab": "core/src/" + } + }, + "require": { + "php": ">=5.3.6", + "pattern-lab/core": "^2.0.0", + "pattern-lab/patternengine-mustache": "^2.0.0", + "pattern-lab/styleguidekit-mustache-default": "^3.0.0" + }, + "scripts": { + "server": "php core/console --server", + "generate": "php core/console --generate", + "watch": "php core/console --watch", + "start": "php core/console --server --with-watch", + "post-install-cmd": [ + "PatternLab\\Installer::postInstallCmd" + ], + "post-update-cmd": [ + "PatternLab\\Installer::postUpdateCmd" + ], + "post-root-package-install": [ + "PatternLab\\Installer::setProjectInstall", + "PatternLab\\Installer::getSuggestedStarterKits", + "PatternLab\\Installer::getConfigOverrides" + ], + "post-package-install": [ + "PatternLab\\Installer::postPackageInstall" + ], + "post-package-update": [ + "PatternLab\\Installer::postPackageUpdate" + ], + "pre-package-uninstall": [ + "PatternLab\\Installer::prePackageUninstall" + ] + }, + "extra": { + "patternlab": { + "starterKitSuggestions": [ + "pattern-lab/starterkit-mustache-demo", + "pattern-lab/starterkit-mustache-base" + ] + } + } +} diff --git a/config/README b/config/.gitkeep similarity index 100% rename from config/README rename to config/.gitkeep diff --git a/core/console b/core/console new file mode 100644 index 0000000..51e4c0d --- /dev/null +++ b/core/console @@ -0,0 +1,46 @@ +dispatch("config.configLoadEnd"); + +// run the console +Console::run(); diff --git a/core/server/router.php b/core/server/router.php new file mode 100644 index 0000000..02bc4c2 --- /dev/null +++ b/core/server/router.php @@ -0,0 +1,41 @@ + false, "packagesRemove" => false, "suggestedStarterKits" => array(), "configOverrides" => array(), "patternLabPackages" => array()); + + /** + * Get any config overrides that may exist for the edition + * @param {Object} a script event object from composer + */ + public static function getConfigOverrides(Event $event) { + + $extra = $event->getComposer()->getPackage()->getExtra(); + if (isset($extra["patternlab"]) && isset($extra["patternlab"]["config"]) && is_array($extra["patternlab"]["config"])) { + self::$installerInfo["configOverrides"] = $extra["patternlab"]["config"]; + } + + } + + /** + * Get the package info from each patternlab-* package's composer.json + * @param {String} the type of event fired during the composer install + * @param {Object} a script event object from composer + */ + public static function getPackageInfo($type, $event) { + + $package = ($type == "update") ? $event->getOperation()->getTargetPackage() : $event->getOperation()->getPackage(); + $packageType = $package->getType(); + $packageExtra = $package->getExtra(); + $packageInfo = array(); + + // make sure we're only evaluating pattern lab packages + if (strpos($packageType,"patternlab-") !== false) { + + $packageInfo["name"] = $package->getName(); + $packageInfo["type"] = $packageType; + $packageInfo["pathBase"] = $event->getComposer()->getInstallationManager()->getInstallPath($package); + $packageInfo["pathDist"] = $packageInfo["pathBase"].DIRECTORY_SEPARATOR."dist".DIRECTORY_SEPARATOR; + $packageInfo["extra"] = (isset($packageExtra["patternlab"])) ? $packageExtra["patternlab"] : array(); + + self::$installerInfo["packages"][] = $packageInfo; + + } + + } + + /** + * Get the suggested starter kits from the root package composer.json + * @param {Object} a script event object from composer + */ + public static function getSuggestedStarterKits(Event $event) { + + $extra = $event->getComposer()->getPackage()->getExtra(); + if (isset($extra["patternlab"]) && isset($extra["patternlab"]["starterKitSuggestions"]) && is_array($extra["patternlab"]["starterKitSuggestions"])) { + self::$installerInfo["suggestedStarterKits"] = $extra["patternlab"]["starterKitSuggestions"]; + } + + } + + /** + * Run the centralized postInstallCmd + * @param {Object} a script event object from composer + */ + public static function postInstallCmd(Event $event) { + + InstallerUtil::postInstallCmd(self::$installerInfo, $event); + + } + + /** + * Run the centralized postUpdateCmd + * @param {Object} a script event object from composer + */ + public static function postUpdateCmd(Event $event) { + + InstallerUtil::postUpdateCmd(self::$installerInfo, $event); + + } + + /** + * Clean-up when a package is removed + * @param {Object} a script event object from composer + */ + public static function postPackageInstall(PackageEvent $event) { + + self::getPackageInfo("install", $event); + + } + + /** + * Clean-up when a package is removed + * @param {Object} a script event object from composer + */ + public static function postPackageUpdate(PackageEvent $event) { + + self::getPackageInfo("update", $event); + + } + + /** + * Clean-up when a package is removed + * @param {Object} a script event object from composer + */ + public static function prePackageUninstall(PackageEvent $event) { + + // make sure the postUpdateCmd doesnt actually do anything + self::setPackagesRemove(); + + // get the basic package info + $package = $event->getOperation()->getPackage(); + $packageType = $package->getType(); + $packageInfo = array(); + + // make sure we're only evaluating pattern lab packages. remove attributes related to them. + if (strpos($packageType,"patternlab-") !== false) { + + $packageInfo["name"] = $package->getName(); + $packageInfo["type"] = $packageType; + $packageInfo["pathBase"] = $event->getComposer()->getInstallationManager()->getInstallPath($package); + + InstallerUtil::packageRemove($packageInfo); + + } + + } + + /** + * Set the packages remove boolean to true + */ + public static function setPackagesRemove() { + + self::$installerInfo["packagesRemove"] = true; + + } + + /** + * Set the project install boolean to true + * @param {Object} a script event object from composer + */ + public static function setProjectInstall(Event $event) { + + self::$installerInfo["projectInstall"] = true; + + } + +} diff --git a/public/README b/public/README deleted file mode 100644 index 5c889f2..0000000 --- a/public/README +++ /dev/null @@ -1,3 +0,0 @@ -To populate this directory you need to generate the PHP version of Pattern Lab for the first time. -To do so either run "php core/builder.php -g" at the command line or, if you're on a Mac, double-click -on "core/scripts/generateSite.command". \ No newline at end of file diff --git a/source/README b/source/.gitkeep similarity index 100% rename from source/README rename to source/.gitkeep