From 1c786edbc6f8be215910ca8bf565ae0292f95ce0 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Thu, 16 May 2013 21:59:41 +0300 Subject: [PATCH] Output of "yii\console\controllers\AssetController::actionCompress()" has been made verbose. --- yii/console/controllers/AssetController.php | 38 ++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/yii/console/controllers/AssetController.php b/yii/console/controllers/AssetController.php index b2a5d12..cee4cc1 100644 --- a/yii/console/controllers/AssetController.php +++ b/yii/console/controllers/AssetController.php @@ -89,13 +89,15 @@ class AssetController extends Controller $targets = $this->loadTargets($this->targets, $bundles); $this->publishBundles($bundles, $this->assetManager); $timestamp = time(); - foreach ($targets as $target) { + foreach ($targets as $name => $target) { + echo "Creating output bundle '{$name}':\n"; if (!empty($target->js)) { $this->buildTarget($target, 'js', $bundles, $timestamp); } if (!empty($target->css)) { $this->buildTarget($target, 'css', $bundles, $timestamp); } + echo "\n"; } $targets = $this->adjustDependency($targets, $bundles); @@ -109,6 +111,8 @@ class AssetController extends Controller */ protected function loadConfiguration($configFile) { + echo "Loading configuration from '{$configFile}'...\n"; + foreach (require($configFile) as $name => $value) { if (property_exists($this, $name)) { $this->$name = $value; @@ -133,6 +137,7 @@ class AssetController extends Controller */ protected function loadBundles($bundles, $extensions) { + echo "Collecting source bundles information...\n"; $result = array(); foreach ($bundles as $name => $bundle) { $bundle['class'] = 'yii\\web\\AssetBundle'; @@ -221,13 +226,16 @@ class AssetController extends Controller */ protected function publishBundles($bundles, $options) { + echo "\nPublishing bundles:\n"; if (!isset($options['class'])) { $options['class'] = 'yii\\web\\AssetManager'; } $am = Yii::createObject($options); - foreach ($bundles as $bundle) { + foreach ($bundles as $name => $bundle) { $bundle->publish($am); + echo " '".$name."' published.\n"; } + echo "\n"; } /** @@ -270,6 +278,8 @@ class AssetController extends Controller */ protected function adjustDependency($targets, $bundles) { + echo "Creating new bundle configuration...\n"; + $map = array(); foreach ($targets as $name => $target) { foreach ($target->depends as $bundle) { @@ -342,7 +352,7 @@ class AssetController extends Controller } $array = var_export($array, true); $version = date('Y-m-d H:i:s', time()); - file_put_contents($bundleFile, <<jsCompressor)) { $tmpFile = $outputFile . '.tmp'; $this->combineJsFiles($inputFiles, $tmpFile); @@ -372,15 +391,24 @@ EOD } else { $log = call_user_func($this->jsCompressor, $this, $inputFiles, $outputFile); } + if (!file_exists($outputFile)) { + throw new Exception("Unable to compress JavaScript files into '{$outputFile}'."); + } + echo " JavaScript files compressed into '{$outputFile}'.\n"; } /** * Compresses given CSS files and combines them into the single one. * @param array $inputFiles list of source file names. * @param string $outputFile output file name. + * @throws \yii\console\Exception on failure */ protected function compressCssFiles($inputFiles, $outputFile) { + if (empty($inputFiles)) { + return; + } + echo " Compressing CSS files...\n"; if (is_string($this->cssCompressor)) { $tmpFile = $outputFile . '.tmp'; $this->combineCssFiles($inputFiles, $tmpFile); @@ -392,6 +420,10 @@ EOD } else { $log = call_user_func($this->cssCompressor, $this, $inputFiles, $outputFile); } + if (!file_exists($outputFile)) { + throw new Exception("Unable to compress CSS files into '{$outputFile}'."); + } + echo " CSS files compressed into '{$outputFile}'.\n"; } /**