Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,56 @@ private function removeSecureEnvironmentValue(string $name): void
unset($this->secureEnvStorage[$name]);
$this->clearEnvironmentCache();
}

/**
* Resolve wildcard theme codes (e.g., Vendor/* to all underlying vendor themes)
*
* @param string[] $themeCodes
* @param \OpenForgeProject\MageForge\Model\ThemeList $themeList
* @return string[]
*/
protected function resolveWildcardThemes(
array $themeCodes,
\OpenForgeProject\MageForge\Model\ThemeList $themeList
): array {
Comment thread
dermatz marked this conversation as resolved.
$resolved = [];
$availableThemes = null;

foreach ($themeCodes as $code) {
if (\str_ends_with($code, '/*')) {
// Lazy-load themes only when needed
if ($availableThemes === null) {
$availableThemes = array_map(
fn($theme) => $theme->getCode(),
$themeList->getAllThemes()
);
}

$prefix = substr($code, 0, -1); // Keeps the trailing slash, e.g. "Vendor/"

Comment thread
dermatz marked this conversation as resolved.
Outdated
$matched = array_filter(
$availableThemes,
fn(string $availableCode) => \str_starts_with($availableCode, $prefix)
);

if (empty($matched)) {
$this->io->warning(sprintf("No themes found for prefix '%s'", $prefix));
} else {
$this->io->note(sprintf(
"Resolved '%s' to %d theme(s): %s",
$code,
count($matched),
implode(', ', $matched)
));
}

array_push($resolved, ...$matched);
} else {
$resolved[] = $code;
}
}

// Return a fresh list without duplicates
return array_values(array_unique($resolved));
}
}
33 changes: 27 additions & 6 deletions src/Console/Command/Theme/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ protected function configure(): void
protected function executeCommand(InputInterface $input, OutputInterface $output): int
{
$themeCodes = $input->getArgument('themeCodes');

// Allow wildcards using the AbstractCommand helper
if (!empty($themeCodes)) {
$themeCodes = $this->resolveWildcardThemes($themeCodes, $this->themeList);

Comment thread
dermatz marked this conversation as resolved.
Outdated
// If wildcards matched nothing and no other explicit themes remain
if (empty($themeCodes)) {
return Command::SUCCESS;
}
}

$isVerbose = $this->isVerbose($output);

if (empty($themeCodes)) {
Expand Down Expand Up @@ -337,12 +348,22 @@ private function processTheme(
private function displayBuildSummary(SymfonyStyle $io, array $successList, float $duration): void
{
$io->newLine();
$io->success(sprintf('🚀 Build process completed in %.2f seconds with the following results:', $duration));
$io->writeln('Summary:');
$io->newLine();

if (empty($successList)) {
$io->warning('No themes were built successfully.');

$successCount = count($successList);

Comment thread
dermatz marked this conversation as resolved.
Outdated
if ($successCount > 0) {
$io->success(sprintf(
'🚀 Successfully built %d theme(s). Build process completed in %.2f seconds.',
$successCount,
$duration
));
$io->writeln('Summary:');
$io->newLine();
} else {
$io->warning(sprintf(
'Build process completed in %.2f seconds, but no themes were built successfully.',
$duration
));
return;
}

Expand Down
9 changes: 9 additions & 0 deletions src/Console/Command/Theme/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ private function resolveThemeCodes(InputInterface $input, OutputInterface $outpu
return $this->getAllThemeCodes();
}

if (!empty($themeCodes)) {
$themeCodes = $this->resolveWildcardThemes($themeCodes, $this->themeList);

Comment thread
dermatz marked this conversation as resolved.
Outdated
// If wildcards matched nothing and no other explicit themes remain
if (empty($themeCodes)) {
return null;
}
}

if (empty($themeCodes)) {
return $this->selectThemesInteractively($output);
}
Expand Down
Loading