mirror of
https://github.com/pattern-lab/edition-php-twig-standard.git
synced 2025-01-17 04:28:14 +01:00
Merge branch 'dev'
This commit is contained in:
commit
73f55743d5
@ -24,7 +24,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.6",
|
"php": ">=5.3.6",
|
||||||
"pattern-lab/core": "0.*",
|
"pattern-lab/core": "0.*",
|
||||||
@ -32,8 +31,16 @@
|
|||||||
"pattern-lab/styleguidekit-twig-default": "0.*"
|
"pattern-lab/styleguidekit-twig-default": "0.*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-create-project-cmd": [
|
"post-install-cmd": [
|
||||||
"PatternLab\\Installer::postCreateProjectCmd"
|
"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": [
|
"post-package-install": [
|
||||||
"PatternLab\\Installer::postPackageInstall"
|
"PatternLab\\Installer::postPackageInstall"
|
||||||
@ -41,9 +48,6 @@
|
|||||||
"post-package-update": [
|
"post-package-update": [
|
||||||
"PatternLab\\Installer::postPackageUpdate"
|
"PatternLab\\Installer::postPackageUpdate"
|
||||||
],
|
],
|
||||||
"pre-install-cmd": [
|
|
||||||
"PatternLab\\Installer::preInstallCmd"
|
|
||||||
],
|
|
||||||
"pre-package-uninstall": [
|
"pre-package-uninstall": [
|
||||||
"PatternLab\\Installer::prePackageUninstall"
|
"PatternLab\\Installer::prePackageUninstall"
|
||||||
]
|
]
|
||||||
|
@ -18,79 +18,145 @@ use \PatternLab\InstallerUtil;
|
|||||||
|
|
||||||
class Installer {
|
class Installer {
|
||||||
|
|
||||||
|
protected static $installerInfo = array("projectInstall" => false, "packagesRemove" => false, "suggestedStarterKits" => array(), "configOverrides" => array(), "patternLabPackages" => array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the PL tasks when a package is installed
|
* Get any config overrides that may exist for the edition
|
||||||
* @param {Object} a script event object from composer
|
* @param {Object} a script event object from composer
|
||||||
*/
|
*/
|
||||||
public static function postCreateProjectCmd(Event $event) {
|
public static function getConfigOverrides(Event $event) {
|
||||||
|
|
||||||
// make sure pattern lab has been loaded
|
$extra = $event->getComposer()->getPackage()->getExtra();
|
||||||
if (class_exists("\PatternLab\Config")) {
|
if (isset($extra["patternlab"]) && isset($extra["patternlab"]["config"]) && is_array($extra["patternlab"]["config"])) {
|
||||||
|
self::$installerInfo["configOverrides"] = $extra["patternlab"]["config"];
|
||||||
|
}
|
||||||
|
|
||||||
InstallerUtil::postCreateProjectCmd($event);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the PL tasks when a package is installed
|
* 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
|
* @param {Object} a script event object from composer
|
||||||
*/
|
*/
|
||||||
public static function postPackageInstall(PackageEvent $event) {
|
public static function postPackageInstall(PackageEvent $event) {
|
||||||
|
|
||||||
// make sure pattern lab has been loaded
|
self::getPackageInfo("install", $event);
|
||||||
if (class_exists("\PatternLab\Config")) {
|
|
||||||
|
|
||||||
InstallerUtil::postPackageInstall($event);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the PL tasks when a package is updated
|
* Clean-up when a package is removed
|
||||||
* @param {Object} a script event object from composer
|
* @param {Object} a script event object from composer
|
||||||
*/
|
*/
|
||||||
public static function postPackageUpdate(PackageEvent $event) {
|
public static function postPackageUpdate(PackageEvent $event) {
|
||||||
|
|
||||||
// make sure pattern lab has been loaded
|
self::getPackageInfo("update", $event);
|
||||||
if (class_exists("\PatternLab\Config")) {
|
|
||||||
|
|
||||||
InstallerUtil::postPackageUpdate($event);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure certain things are set-up before running composer's install
|
* Clean-up when a package is removed
|
||||||
* @param {Object} a script event object from composer
|
|
||||||
*/
|
|
||||||
public static function preInstallCmd(Event $event) {
|
|
||||||
|
|
||||||
// make sure pattern lab has been loaded
|
|
||||||
if (class_exists("\PatternLab\Config")) {
|
|
||||||
|
|
||||||
InstallerUtil::preInstallCmd($event);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the PL tasks when a package is removed
|
|
||||||
* @param {Object} a script event object from composer
|
* @param {Object} a script event object from composer
|
||||||
*/
|
*/
|
||||||
public static function prePackageUninstall(PackageEvent $event) {
|
public static function prePackageUninstall(PackageEvent $event) {
|
||||||
|
|
||||||
// make sure pattern lab has been loaded
|
// make sure the postUpdateCmd doesnt actually do anything
|
||||||
if (class_exists("\PatternLab\Config")) {
|
self::setPackagesRemove();
|
||||||
|
|
||||||
InstallerUtil::prePackageUninstallCmd($event);
|
// 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user