diff --git a/src/Console/Commands/Compose.php b/src/Console/Commands/Compose.php index 4aa086a9..9606dd4b 100644 --- a/src/Console/Commands/Compose.php +++ b/src/Console/Commands/Compose.php @@ -13,14 +13,17 @@ use BrianHenryIE\Strauss\Prefixer; use BrianHenryIE\Strauss\Composer\Extra\StraussConfig; use Exception; -use RegexIterator; +use Psr\Log\LoggerAwareTrait; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Logger\ConsoleLogger; use Symfony\Component\Console\Output\OutputInterface; class Compose extends Command { + use LoggerAwareTrait; + protected OutputInterface $output; /** @var string */ @@ -69,6 +72,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $this->output = $output; + $this->setLogger(new ConsoleLogger($output)); + $workingDir = getcwd() . DIRECTORY_SEPARATOR; $this->workingDir = $workingDir; @@ -110,6 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ protected function loadProjectComposerPackage(InputInterface $input): void { + $this->logger->info('Loading config...'); $this->projectComposerPackage = new ProjectComposerPackage($this->workingDir); @@ -133,6 +139,7 @@ protected function loadProjectComposerPackage(InputInterface $input): void */ protected function buildDependencyList(): void { + $this->logger->info('Building dependency list...'); $requiredPackageNames = $this->config->getPackages(); @@ -204,6 +211,7 @@ protected function recursiveGetAllDependencies(array $requiredPackageNames): voi protected function enumerateFiles(): void { + $this->logger->info('Enumerating files...'); $this->fileEnumerator = new FileEnumerator( $this->flatDependencyTree, @@ -239,6 +247,7 @@ protected function copyFiles(): void // 4. Determine namespace and classname changes protected function determineChanges(): void { + $this->logger->info('Determining changes...'); $this->changeEnumerator = new ChangeEnumerator($this->config); @@ -251,6 +260,8 @@ protected function determineChanges(): void // Replace references to updated namespaces and classnames throughout the dependencies. protected function performReplacements(): void { + $this->logger->info('Performing replacements...'); + $this->replacer = new Prefixer($this->config, $this->workingDir); $namespaces = $this->changeEnumerator->getDiscoveredNamespaces($this->config->getNamespacePrefix()); @@ -317,6 +328,7 @@ protected function performReplacementsInProjectFiles(): void protected function addLicenses(): void { + $this->logger->info('Adding licenses...'); $author = $this->projectComposerPackage->getAuthor(); @@ -340,6 +352,8 @@ protected function generateAutoloader(): void return; } + $this->logger->info('Generating autoloader...'); + $files = $this->fileEnumerator->getFilesAutoloaders(); $classmap = new Autoload($this->config, $this->workingDir, $files); @@ -367,10 +381,14 @@ protected function cleanUp(): void return; } + $this->logger->info('Cleaning up...'); + $cleanup = new Cleanup($this->config, $this->workingDir); $sourceFiles = array_keys($this->fileEnumerator->getAllFilesAndDependencyList()); + // TODO: For files autoloaders, delete the contents of the file, not the file itself. + // This will check the config to check should it delete or not. $cleanup->cleanup($sourceFiles); }