Skip to content

Commit 7394b66

Browse files
committed
fix: add missing ConsoleFacade and ConsoleFactory methods
1 parent 30b3ca0 commit 7394b66

File tree

3 files changed

+175
-5
lines changed

3 files changed

+175
-5
lines changed

src/Console/ConsoleFacade.php

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

77
use Gacela\Console\Domain\AllAppModules\AppModule;
88
use Gacela\Console\Domain\CommandArguments\CommandArguments;
9+
use Gacela\Console\Domain\DependencyAnalyzer\TModuleDependency;
910
use Gacela\Framework\AbstractFacade;
1011

12+
use function function_exists;
13+
1114
/**
1215
* @extends AbstractFacade<ConsoleFactory>
1316
*/
@@ -71,4 +74,103 @@ public function getContainerDependencyTree(string $className): array
7174
{
7275
return $this->getFactory()->getContainerDependencyTree($className);
7376
}
77+
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+
106+
public function compileContainer(): string
107+
{
108+
return $this->getFactory()->createContainerCompiler()->compile(
109+
$this->getFactory()->getMainContainer(),
110+
);
111+
}
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+
}
74176
}

src/Console/ConsoleFactory.php

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@
99
use Gacela\Console\Domain\AllAppModules\AppModuleCreator;
1010
use Gacela\Console\Domain\CommandArguments\CommandArgumentsParser;
1111
use Gacela\Console\Domain\CommandArguments\CommandArgumentsParserInterface;
12+
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;
1219
use Gacela\Console\Domain\FileContent\FileContentGenerator;
1320
use Gacela\Console\Domain\FileContent\FileContentGeneratorInterface;
1421
use Gacela\Console\Domain\FileContent\FileContentIoInterface;
1522
use Gacela\Console\Domain\FilenameSanitizer\FilenameSanitizer;
1623
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;
1727
use Gacela\Console\Infrastructure\FileContentIo;
1828
use Gacela\Framework\AbstractFactory;
1929
use Gacela\Framework\ClassResolver\Config\ConfigResolver;
@@ -102,6 +112,51 @@ public function getContainerDependencyTree(string $className): array
102112
return $this->getMainContainer()->getDependencyTree($className);
103113
}
104114

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+
130+
public function createContainerCompiler(): ContainerCompiler
131+
{
132+
return new ContainerCompiler();
133+
}
134+
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+
105160
/**
106161
* @return RecursiveIteratorIterator<RecursiveDirectoryIterator>
107162
*/
@@ -127,9 +182,4 @@ private function getTemplateByFilenameMap(): array
127182
{
128183
return (array)$this->getProvidedDependency(ConsoleProvider::TEMPLATE_BY_FILENAME_MAP);
129184
}
130-
131-
private function getMainContainer(): Container
132-
{
133-
return Gacela::container();
134-
}
135185
}

src/Console/ConsoleProvider.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55
namespace Gacela\Console;
66

77
use Gacela\Console\Domain\FilenameSanitizer\FilenameSanitizer;
8+
use Gacela\Console\Infrastructure\Command\AnalyzeDependenciesCommand;
89
use Gacela\Console\Infrastructure\Command\CacheWarmCommand;
10+
use Gacela\Console\Infrastructure\Command\ContainerCompileCommand;
911
use Gacela\Console\Infrastructure\Command\DebugContainerCommand;
12+
use Gacela\Console\Infrastructure\Command\DevWatchCommand;
13+
use Gacela\Console\Infrastructure\Command\DocsGenerateCommand;
14+
use Gacela\Console\Infrastructure\Command\ExploreCommand;
15+
use Gacela\Console\Infrastructure\Command\GenerateIdeHelperCommand;
16+
use Gacela\Console\Infrastructure\Command\ListDeprecatedCommand;
1017
use Gacela\Console\Infrastructure\Command\ListModulesCommand;
1118
use Gacela\Console\Infrastructure\Command\MakeFileCommand;
1219
use Gacela\Console\Infrastructure\Command\MakeModuleCommand;
20+
use Gacela\Console\Infrastructure\Command\ProfileReportCommand;
1321
use Gacela\Console\Infrastructure\Command\ValidateConfigCommand;
22+
use Gacela\Console\Infrastructure\Command\VersionCheckCommand;
1423
use Gacela\Framework\AbstractProvider;
1524
use Gacela\Framework\Container\Container;
1625

@@ -38,6 +47,15 @@ private function addCommands(Container $container): void
3847
new DebugContainerCommand(),
3948
new CacheWarmCommand(),
4049
new ValidateConfigCommand(),
50+
new AnalyzeDependenciesCommand(),
51+
new ContainerCompileCommand(),
52+
new GenerateIdeHelperCommand(),
53+
new DevWatchCommand(),
54+
new DocsGenerateCommand(),
55+
new ExploreCommand(),
56+
new VersionCheckCommand(),
57+
new ListDeprecatedCommand(),
58+
new ProfileReportCommand(),
4159
]);
4260
}
4361

0 commit comments

Comments
 (0)