Skip to content

Commit 24111ae

Browse files
Display information when downloading a file.
1 parent 1374e10 commit 24111ae

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

src/FileFetcher.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace DrupalComposer\DrupalScaffold;
99

10+
use Composer\IO\IOInterface;
1011
use Composer\Util\Filesystem;
1112
use Composer\Util\RemoteFilesystem;
1213

@@ -17,12 +18,18 @@ class FileFetcher {
1718
*/
1819
protected $remoteFilesystem;
1920

21+
/**
22+
* @var \Composer\IO\IOInterface
23+
*/
24+
protected $io;
25+
2026
protected $source;
2127
protected $filenames;
2228
protected $fs;
2329

24-
public function __construct(RemoteFilesystem $remoteFilesystem, $source, $filenames = []) {
30+
public function __construct(RemoteFilesystem $remoteFilesystem, $source, $filenames = [], IOInterface $io) {
2531
$this->remoteFilesystem = $remoteFilesystem;
32+
$this->io = $io;
2633
$this->source = $source;
2734
$this->filenames = $filenames;
2835
$this->fs = new Filesystem();
@@ -32,7 +39,13 @@ public function fetch($version, $destination) {
3239
array_walk($this->filenames, function ($filename) use ($version, $destination) {
3340
$url = $this->getUri($filename, $version);
3441
$this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
42+
$this->io->write("Going to download the file $filename");
43+
$this->io->write(" from: $url");
44+
$this->io->write(" to: $destination/$filename");
3545
$this->remoteFilesystem->copy($url, $url, $destination . '/' . $filename);
46+
// Used to put a new line because the remote file system does not put
47+
// one.
48+
$this->io->write('');
3649
});
3750
}
3851

src/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function downloadScaffold() {
116116
$fetcher = new PrestissimoFileFetcher($remoteFs, $options['source'], $files, $this->io, $this->composer->getConfig());
117117
$fetcher->fetch($version, $webroot);
118118

119-
$initialFileFetcher = new InitialFileFetcher($remoteFs, $options['source'], $this->getInitial());
119+
$initialFileFetcher = new InitialFileFetcher($remoteFs, $options['source'], $this->getInitial(), $this->io);
120120
$initialFileFetcher->fetch($version, $webroot);
121121

122122
// Call post-scaffold scripts.

src/InitialFileFetcher.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ public function fetch($version, $destination) {
1515
if (!file_exists($target)) {
1616
$url = $this->getUri($sourceFilename, $version);
1717
$this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
18+
$this->io->write("Going to download the file $filename");
19+
$this->io->write(" from: $url");
20+
$this->io->write(" to: $target");
1821
$this->remoteFilesystem->copy($url, $url, $target);
22+
// Used to put a new line because the remote file system does not put
23+
// one.
24+
$this->io->write('');
1925
}
2026
});
2127
}

src/PrestissimoFileFetcher.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@
1414

1515
class PrestissimoFileFetcher extends FileFetcher {
1616

17-
/**
18-
* @var \Composer\IO\IOInterface
19-
*/
20-
protected $io;
21-
2217
/**
2318
* @var \Composer\Config
2419
*/
2520
protected $config;
2621

2722
public function __construct(\Composer\Util\RemoteFilesystem $remoteFilesystem, $source, array $filenames = [], IOInterface $io, Config $config) {
28-
parent::__construct($remoteFilesystem, $source, $filenames);
29-
$this->io = $io;
23+
parent::__construct($remoteFilesystem, $source, $filenames, $io);
3024
$this->config = $config;
3125
}
3226

@@ -43,7 +37,10 @@ protected function fetchWithPrestissimo($version, $destination) {
4337
array_walk($this->filenames, function ($filename) use ($version, $destination, &$requests) {
4438
$url = $this->getUri($filename, $version);
4539
$this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
40+
$this->io->write("Going to download the file $filename");
41+
$this->io->write(" from: $url");
4642
$requests[] = new CopyRequest($url, $destination . '/' . $filename, false, $this->io, $this->config);
43+
$this->io->write(" to: $destination/$filename");
4744
});
4845

4946
$successCnt = $failureCnt = 0;

0 commit comments

Comments
 (0)