Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Commit

Permalink
updated to Craft 3.0.0, --verbose option
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Stark committed Apr 11, 2018
1 parent cf99b7d commit aafb737
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# AssetBundler Changelog

## 0.6.0 - 2018-04-12
### Changed
- Updated dependency `craftcms/cms:^3.0.0
- No need to set @web & @webroot alias anymore, Thanks: @timkelty
- Added `--verbose` / `-v` option to display the list of changed files (default `false)

## 0.5.0 - 2018-04-10
### Changed
- New namespace for cli commands `craft asset-bundler/*`
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fortrabbit/craft-asset-bundler",
"description": "Provides a console command to publish web/cpresources",
"type": "craft-plugin",
"version": "0.5.0",
"version": "0.6.0",
"keywords": [
"craft",
"cms",
Expand Down
16 changes: 15 additions & 1 deletion src/Commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,25 @@ class Commands extends BaseConsoleController

public $defaultAction = 'publish';

public $verbose = false;

public function options($actionID)
{
return ($actionID === 'publish') ? ['verbose'] : [];
}

public function optionAliases()
{
return ['v' => 'verbose'];
}

public function actions()
{
return [
'publish' => PublishAction::class,
'publish' => [
'class' => PublishAction::class,
'verbose' => $this->verbose
],
'cleanup' => CleanupAction::class,
];
}
Expand Down
15 changes: 13 additions & 2 deletions src/commands/PublishAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
class PublishAction extends Action
{

/**
* @var bool
*/
public $verbose;

/**
* Publish assets to cpresources
*
Expand Down Expand Up @@ -86,8 +91,10 @@ public function run()
$oldRev = $am->getRevision();
$am->updateRevision();
$newRev = $am->getRevision();

$this->printModifiedFiles($am->modifiedFiles, $oldRev, $newRev);


}


Expand Down Expand Up @@ -129,9 +136,13 @@ protected function printModifiedFiles(array $files, $oldRev = null, $newRev = nu

echo "Revision change: $oldRev > $newRev" . PHP_EOL;
echo str_repeat('-', 50) . PHP_EOL;
foreach ($files as $file) {
echo $file . PHP_EOL;

if ($this->verbose) {
foreach ($files as $file) {
echo $file . PHP_EOL;
}
}

} else {
echo "No files changes" . PHP_EOL;
}
Expand Down

0 comments on commit aafb737

Please sign in to comment.