Commit 1c786edb by Klimov Paul

Output of "yii\console\controllers\AssetController::actionCompress()" has been made verbose.

parent c676e92d
......@@ -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, <<<EOD
$bytesWritten = file_put_contents($bundleFile, <<<EOD
<?php
/**
* This file is generated by the "yiic script" command.
......@@ -352,15 +362,24 @@ class AssetController extends Controller
return $array;
EOD
);
if ($bytesWritten <= 0) {
throw new Exception("Unable to write output bundle configuration at '{$bundleFile}'.");
}
echo "Output bundle configuration created at '{$bundleFile}'.\n";
}
/**
* Compresses given Java Script 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 compressJsFiles($inputFiles, $outputFile)
{
if (empty($inputFiles)) {
return;
}
echo " Compressing JavaScript files...\n";
if (is_string($this->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";
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment