Skip to content

Commit 7be8969

Browse files
committed
fix: add minimal Console changes for container compiler only
1 parent 051885f commit 7be8969

File tree

2 files changed

+5
-144
lines changed

2 files changed

+5
-144
lines changed

src/Console/ConsoleFacade.php

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66

77
use Gacela\Console\Domain\AllAppModules\AppModule;
88
use Gacela\Console\Domain\CommandArguments\CommandArguments;
9-
use Gacela\Console\Domain\DependencyAnalyzer\TModuleDependency;
109
use Gacela\Framework\AbstractFacade;
1110

12-
use function function_exists;
13-
1411
/**
1512
* @extends AbstractFacade<ConsoleFactory>
1613
*/
@@ -75,102 +72,10 @@ public function getContainerDependencyTree(string $className): array
7572
return $this->getFactory()->getContainerDependencyTree($className);
7673
}
7774

78-
/**
79-
* @param list<AppModule> $modules
80-
*
81-
* @return list<TModuleDependency>
82-
*/
83-
public function analyzeModuleDependencies(array $modules): array
84-
{
85-
return $this->getFactory()->createDependencyAnalyzer()->analyzeModules($modules);
86-
}
87-
88-
/**
89-
* @param list<TModuleDependency> $dependencies
90-
*
91-
* @return list<array{from: string, to: string}>
92-
*/
93-
public function detectCircularDependencies(array $dependencies): array
94-
{
95-
return $this->getFactory()->createDependencyAnalyzer()->detectCircularDependencies($dependencies);
96-
}
97-
98-
/**
99-
* @param list<TModuleDependency> $dependencies
100-
*/
101-
public function formatDependencies(array $dependencies, string $format): string
102-
{
103-
return $this->getFactory()->createDependencyFormatter($format)->format($dependencies);
104-
}
105-
10675
public function compileContainer(): string
10776
{
10877
return $this->getFactory()->createContainerCompiler()->compile(
10978
$this->getFactory()->getMainContainer(),
11079
);
11180
}
112-
113-
/**
114-
* @param list<AppModule> $modules
115-
*/
116-
public function generateIdeHelperMeta(array $modules): string
117-
{
118-
return $this->getFactory()->createIdeHelperGenerator()->generatePhpStormMeta($modules);
119-
}
120-
121-
/**
122-
* @return list<string>
123-
*/
124-
public function generateTemplateFiles(
125-
CommandArguments $arguments,
126-
string $template,
127-
bool $withTests,
128-
bool $withApi,
129-
): array {
130-
return $this->getFactory()
131-
->createModuleTemplateGenerator()
132-
->generateTemplateFiles($arguments, $template, $withTests, $withApi);
133-
}
134-
135-
/**
136-
* @param list<string> $watchPaths
137-
*/
138-
public function initializeFileWatcher(array $watchPaths): void
139-
{
140-
$this->getFactory()->createFileWatcher()->initialize($watchPaths);
141-
}
142-
143-
/**
144-
* @param list<string> $watchPaths
145-
*
146-
* @return list<string>
147-
*/
148-
public function detectFileChanges(array $watchPaths): array
149-
{
150-
return $this->getFactory()->createFileWatcher()->detectChanges($watchPaths);
151-
}
152-
153-
public function clearDevelopmentCaches(): void
154-
{
155-
// Clear opcache if available
156-
if (function_exists('opcache_reset')) {
157-
opcache_reset();
158-
}
159-
160-
// Clear realpath cache
161-
clearstatcache(true);
162-
163-
// Clear Gacela's internal caches
164-
$this->getFactory()->getMainContainer()->remove('cache');
165-
}
166-
167-
/**
168-
* @param list<array{from: string, to: string}> $dependencies
169-
*/
170-
public function generateModuleDocumentation(AppModule $module, array $dependencies): string
171-
{
172-
return $this->getFactory()
173-
->createDocumentationGenerator()
174-
->generateModuleDocumentation($module, $dependencies);
175-
}
17681
}

src/Console/ConsoleFactory.php

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,11 @@
1010
use Gacela\Console\Domain\CommandArguments\CommandArgumentsParser;
1111
use Gacela\Console\Domain\CommandArguments\CommandArgumentsParserInterface;
1212
use Gacela\Console\Domain\ContainerCompiler\ContainerCompiler;
13-
use Gacela\Console\Domain\DependencyAnalyzer\DependencyAnalyzer;
14-
use Gacela\Console\Domain\DependencyAnalyzer\DependencyFormatterInterface;
15-
use Gacela\Console\Domain\DependencyAnalyzer\GraphvizFormatter;
16-
use Gacela\Console\Domain\DependencyAnalyzer\JsonFormatter;
17-
use Gacela\Console\Domain\DependencyAnalyzer\MermaidFormatter;
18-
use Gacela\Console\Domain\DocumentationGenerator\DocumentationGenerator;
1913
use Gacela\Console\Domain\FileContent\FileContentGenerator;
2014
use Gacela\Console\Domain\FileContent\FileContentGeneratorInterface;
2115
use Gacela\Console\Domain\FileContent\FileContentIoInterface;
2216
use Gacela\Console\Domain\FilenameSanitizer\FilenameSanitizer;
2317
use Gacela\Console\Domain\FilenameSanitizer\FilenameSanitizerInterface;
24-
use Gacela\Console\Domain\FileWatcher\FileWatcher;
25-
use Gacela\Console\Domain\IdeHelper\IdeHelperGenerator;
26-
use Gacela\Console\Domain\ModuleTemplate\ModuleTemplateGenerator;
2718
use Gacela\Console\Infrastructure\FileContentIo;
2819
use Gacela\Framework\AbstractFactory;
2920
use Gacela\Framework\ClassResolver\Config\ConfigResolver;
@@ -112,51 +103,11 @@ public function getContainerDependencyTree(string $className): array
112103
return $this->getMainContainer()->getDependencyTree($className);
113104
}
114105

115-
public function createDependencyAnalyzer(): DependencyAnalyzer
116-
{
117-
return new DependencyAnalyzer();
118-
}
119-
120-
public function createDependencyFormatter(string $format): DependencyFormatterInterface
121-
{
122-
return match ($format) {
123-
'mermaid' => new MermaidFormatter(),
124-
'graphviz', 'dot' => new GraphvizFormatter(),
125-
'json' => new JsonFormatter(),
126-
default => new JsonFormatter(),
127-
};
128-
}
129-
130106
public function createContainerCompiler(): ContainerCompiler
131107
{
132108
return new ContainerCompiler();
133109
}
134110

135-
public function createIdeHelperGenerator(): IdeHelperGenerator
136-
{
137-
return new IdeHelperGenerator();
138-
}
139-
140-
public function createModuleTemplateGenerator(): ModuleTemplateGenerator
141-
{
142-
return new ModuleTemplateGenerator();
143-
}
144-
145-
public function createFileWatcher(): FileWatcher
146-
{
147-
return new FileWatcher();
148-
}
149-
150-
public function createDocumentationGenerator(): DocumentationGenerator
151-
{
152-
return new DocumentationGenerator();
153-
}
154-
155-
public function getMainContainer(): Container
156-
{
157-
return Gacela::container();
158-
}
159-
160111
/**
161112
* @return RecursiveIteratorIterator<RecursiveDirectoryIterator>
162113
*/
@@ -182,4 +133,9 @@ private function getTemplateByFilenameMap(): array
182133
{
183134
return (array)$this->getProvidedDependency(ConsoleProvider::TEMPLATE_BY_FILENAME_MAP);
184135
}
136+
137+
private function getMainContainer(): Container
138+
{
139+
return Gacela::container();
140+
}
185141
}

0 commit comments

Comments
 (0)