|
24 | 24 | use FastForward\DevTools\Filesystem\FinderFactoryInterface; |
25 | 25 | use FastForward\DevTools\Filesystem\FilesystemInterface; |
26 | 26 | use FastForward\DevTools\Resource\FileDiffer; |
27 | | -use Psr\Log\LoggerInterface; |
28 | 27 | use Psr\Log\LogLevel; |
29 | 28 | use Symfony\Component\Config\FileLocatorInterface; |
30 | 29 | use Symfony\Component\Console\Attribute\AsCommand; |
@@ -56,15 +55,13 @@ final class CopyResourceCommand extends Command |
56 | 55 | * @param FileLocatorInterface $fileLocator the locator used to resolve source resources |
57 | 56 | * @param FinderFactoryInterface $finderFactory the factory used to create finders for directory resources |
58 | 57 | * @param FileDiffer $fileDiffer the service used to summarize overwrite changes |
59 | | - * @param LoggerInterface $logger the output-aware logger |
60 | 58 | * @param SymfonyStyle $io the input/output service used to interact with the user |
61 | 59 | */ |
62 | 60 | public function __construct( |
63 | 61 | private readonly FilesystemInterface $filesystem, |
64 | 62 | private readonly FileLocatorInterface $fileLocator, |
65 | 63 | private readonly FinderFactoryInterface $finderFactory, |
66 | 64 | private readonly FileDiffer $fileDiffer, |
67 | | - private readonly LoggerInterface $logger, |
68 | 65 | private readonly SymfonyStyle $io, |
69 | 66 | ) { |
70 | 67 | parent::__construct(); |
@@ -162,11 +159,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
162 | 159 | * @param string $sourcePath the resolved source directory |
163 | 160 | * @param string $targetPath the resolved target directory |
164 | 161 | * @param bool $overwrite whether existing files MAY be overwritten |
| 162 | + * @param bool $dryRun whether the command is previewing changes only |
| 163 | + * @param bool $check whether the command SHOULD fail on detected drift |
| 164 | + * @param bool $interactive whether the command SHOULD prompt before overwriting drifted files |
| 165 | + * @param InputInterface $input the originating command input |
165 | 166 | * @param OutputInterface $output the output used to report copy results |
166 | | - * @param bool $dryRun |
167 | | - * @param bool $check |
168 | | - * @param bool $interactive |
169 | | - * @param InputInterface $input |
170 | 167 | * |
171 | 168 | * @return int the command status code |
172 | 169 | */ |
@@ -213,11 +210,11 @@ private function copyDirectory( |
213 | 210 | * @param string $sourcePath the resolved source file |
214 | 211 | * @param string $targetPath the resolved target file |
215 | 212 | * @param bool $overwrite whether an existing target file MAY be overwritten |
| 213 | + * @param bool $dryRun whether the command is previewing changes only |
| 214 | + * @param bool $check whether the command SHOULD fail on detected drift |
| 215 | + * @param bool $interactive whether the command SHOULD prompt before overwriting drifted files |
| 216 | + * @param InputInterface $input the originating command input |
216 | 217 | * @param OutputInterface $output the output used to report copy results |
217 | | - * @param bool $dryRun |
218 | | - * @param bool $check |
219 | | - * @param bool $interactive |
220 | | - * @param InputInterface $input |
221 | 218 | * |
222 | 219 | * @return int the command status code |
223 | 220 | */ |
@@ -246,27 +243,29 @@ private function copyFile( |
246 | 243 | if (($overwrite || $dryRun || $check || $interactive) && $this->filesystem->exists($targetPath)) { |
247 | 244 | $comparison = $this->fileDiffer->diff($sourcePath, $targetPath); |
248 | 245 |
|
249 | | - $this->notice( |
| 246 | + $this->log( |
250 | 247 | $comparison->getSummary(), |
251 | 248 | $input, |
252 | 249 | [ |
253 | 250 | 'source_path' => $sourcePath, |
254 | 251 | 'target_path' => $targetPath, |
255 | 252 | ], |
| 253 | + LogLevel::NOTICE, |
256 | 254 | ); |
257 | 255 |
|
258 | 256 | if ($comparison->isChanged()) { |
259 | 257 | $consoleDiff = $this->fileDiffer->formatForConsole($comparison->getDiff(), $output->isDecorated()); |
260 | 258 |
|
261 | 259 | if (null !== $consoleDiff) { |
262 | | - $this->notice( |
| 260 | + $this->log( |
263 | 261 | $consoleDiff, |
264 | 262 | $input, |
265 | 263 | [ |
266 | 264 | 'source_path' => $sourcePath, |
267 | 265 | 'target_path' => $targetPath, |
268 | 266 | 'diff' => $comparison->getDiff(), |
269 | 267 | ], |
| 268 | + LogLevel::NOTICE, |
270 | 269 | ); |
271 | 270 | } |
272 | 271 | } |
|
0 commit comments