Skip to content

Commit

Permalink
Add basic output
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHenryIE committed Dec 6, 2023
1 parent 3342eda commit 5f3698e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Console/Commands/Compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -133,6 +139,7 @@ protected function loadProjectComposerPackage(InputInterface $input): void
*/
protected function buildDependencyList(): void
{
$this->logger->info('Building dependency list...');

$requiredPackageNames = $this->config->getPackages();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand All @@ -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());
Expand Down Expand Up @@ -317,6 +328,7 @@ protected function performReplacementsInProjectFiles(): void

protected function addLicenses(): void
{
$this->logger->info('Adding licenses...');

$author = $this->projectComposerPackage->getAuthor();

Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5f3698e

Please sign in to comment.