Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.

Commit 958bcc0

Browse files
authored
Merge pull request #161 from xemlock/console-output
Add console output
2 parents 2f7c472 + df08bc2 commit 958bcc0

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/Bowerphp/Bowerphp.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,17 @@ public function installPackage(PackageInterface $package, InstallerInterface $in
105105

106106
// if package is already installed, match current version with latest available version
107107
if ($this->isPackageInstalled($package)) {
108+
$this->output->writelnInfoPackage($package, 'validate', sprintf('%s against %s#%s', $packageTag, $package->getName(), $package->getRequiredVersion()));
108109
$packageBower = $this->config->getPackageBowerFileContent($package);
109110
if ($packageTag == $packageBower['version']) {
110111
// if version is fully matching, there's no need to install
111112
return;
112113
}
113114
}
114115

115-
$this->output->writelnInfoPackage($package);
116-
117-
$this->output->writelnInstalledPackage($package);
118-
119116
$this->cachePackage($package);
120117

118+
$this->output->writelnInstalledPackage($package);
121119
$installer->install($package);
122120

123121
$overrides = $this->config->getOverrideFor($package->getName());
@@ -182,17 +180,18 @@ public function updatePackage(PackageInterface $package, InstallerInterface $ins
182180
$package->setRequires(isset($bower['dependencies']) ? $bower['dependencies'] : null);
183181

184182
$packageTag = $this->getPackageTag($package);
183+
$this->output->writelnInfoPackage($package, 'validate', sprintf('%s against %s#%s', $packageTag, $package->getName(), $package->getRequiredVersion()));
184+
185185
$package->setRepository($this->repository);
186186
if ($packageTag == $package->getVersion()) {
187187
// if version is fully matching, there's no need to update
188188
return;
189189
}
190190
$package->setVersion($packageTag);
191191

192-
$this->output->writelnUpdatingPackage($package);
193-
194192
$this->cachePackage($package);
195193

194+
$this->output->writelnUpdatingPackage($package);
196195
$installer->update($package);
197196

198197
$overrides = $this->config->getOverrideFor($package->getName());
@@ -448,6 +447,8 @@ protected function findPackage($name)
448447
*/
449448
private function cachePackage(PackageInterface $package)
450449
{
450+
$this->output->writelnInfoPackage($package, 'download');
451+
451452
// get release archive from repository
452453
$file = $this->repository->getRelease();
453454

src/Bowerphp/Output/BowerphpConsoleOutput.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ public function __construct(OutputInterface $output)
3131
* writelnInfoPackage
3232
*
3333
* @param PackageInterface $package
34+
* @param string $action
35+
* @param string $message
3436
*/
35-
public function writelnInfoPackage(PackageInterface $package)
37+
public function writelnInfoPackage(PackageInterface $package, $action = '', $message = '')
3638
{
37-
$this->output->writeln(sprintf('bower <info>%s</info>',
38-
str_pad($package->getName() . '#' . $package->getRequiredVersion(), 21, ' ', STR_PAD_RIGHT)
39+
$this->output->writeln(sprintf('bower <info>%s</info> <fg=cyan>%s</fg=cyan> %s',
40+
str_pad($package->getName() . '#' . $package->getRequiredVersion(), 21, ' ', STR_PAD_RIGHT),
41+
str_pad($action, 10, ' ', STR_PAD_LEFT),
42+
$message
3943
));
4044
}
4145

tests/Bowerphp/Test/BowerphpTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ public function testDoNotInstallAlreadyInstalledPackage()
204204
->shouldReceive('install')->never()
205205
;
206206

207+
$this->output
208+
->shouldReceive('writelnInfoPackage')
209+
;
210+
207211
//$this->filesystem
208212
// ->shouldReceive('exists')->with(getcwd() . '/bower_components/jquery/.bower.json')->andReturn(false)
209213
// ->shouldReceive('dumpFile')->with('./tmp/jquery', "fileAsString...", 0644)

tests/Bowerphp/Test/Output/BowerphpConsoleOutputTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testWritelnInfoPackage()
2828
;
2929

3030
$output
31-
->shouldReceive('writeln')->with('bower <info>jquery#2.1 </info>')
31+
->shouldReceive('writeln')->with('bower <info>jquery#2.1 </info> <fg=cyan> </fg=cyan> ')
3232
;
3333

3434
$bConsoleOutput = new BowerphpConsoleOutput($output);

0 commit comments

Comments
 (0)