Skip to content

Commit 9fc1739

Browse files
authored
Improved Build Status (#36)
* docs: update command descriptions and add shortcodes in README.md feat: enhance theme building process with detailed spinner messages and summary output * style: update comments to English in BuildCommand.php
1 parent c22a3f5 commit 9fc1739

File tree

2 files changed

+59
-24
lines changed

2 files changed

+59
-24
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ Please ensure that your Magento installation meets this requirement before insta
3636

3737
### Available Commands
3838

39-
| Command | Description |
40-
|---------------------------|-------------------------------------------------------------|
41-
| `mageforge:version` | Shows current and latest version of the module |
42-
| `mageforge:system-check` | Get system information (OS, PHP, Database, Node.js, etc.) |
43-
| `mageforge:theme:list` | Lists all available themes |
44-
| `mageforge:theme:build` | Builds selected themes (CSS/TailwindCSS) |
45-
| `mageforge:theme:watch` | Starts watch mode for theme development |
39+
| Command | Description | Shortcodes |
40+
|---------------------------|-------------------------------------------------------------|-----------------------------------|
41+
| `mageforge:system:version` | Shows current and latest version of the module | `m:s:v` |
42+
| `mageforge:system:check` | Get system information (OS, PHP, Database, Node.js, etc.) | `m:s:c` |
43+
| `mageforge:theme:list` | Lists all available themes | `m:t:l` |
44+
| `mageforge:theme:build` | Builds selected themes (CSS/TailwindCSS) | `m:t:b`, `frontend:build` |
45+
| `mageforge:theme:watch` | Starts watch mode for theme development | `m:t:w`, `frontend:watch` |
46+
4647

4748
---
4849

@@ -90,7 +91,9 @@ bin/magento setup:upgrade
9091

9192
- Use the `-v` option for more detailed output
9293
- Watch mode supports hot-reloading for LESS and Tailwind
93-
- Check system information anytime with `mageforge:system-check`
94+
- Check system information anytime with `mageforge:system:check`
95+
- Use shortcodes for faster command execution, for example `bin/magento m:t:b` instead of `bin/magento mageforge:theme:build`
96+
- Theme build and watch commands have special aliases: `frontend:build` and `frontend:watch`
9497

9598
## Extending MageForge
9699

src/Console/Command/Theme/BuildCommand.php

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,38 @@ private function processBuildThemes(
114114
): int {
115115
$startTime = microtime(true);
116116
$successList = [];
117+
$totalThemes = count($themeCodes);
117118

118119
if ($isVerbose) {
119-
$io->title(sprintf('Building %d theme(s)', count($themeCodes)));
120+
$io->title(sprintf('Building %d theme(s)', $totalThemes));
120121

121122
foreach ($themeCodes as $themeCode) {
122123
if (!$this->processTheme($themeCode, $io, $output, $isVerbose, $successList)) {
123124
continue;
124125
}
125126
}
126127
} else {
127-
// Nutze Spinner mit der korrekten API
128-
$spinner = new Spinner('✨ Building theme ...');
129-
$spinner->spin(function() use ($themeCodes, $io, $output, $isVerbose, &$successList) {
130-
foreach ($themeCodes as $themeCode) {
131-
if (!$this->processTheme($themeCode, $io, $output, $isVerbose, $successList)) {
132-
continue;
133-
}
128+
// Use the existing spinner with a customized message
129+
foreach ($themeCodes as $index => $themeCode) {
130+
$currentTheme = $index + 1;
131+
// Show which theme is currently being built
132+
$themeNameCyan = sprintf("<fg=cyan>%s</>", $themeCode);
133+
$spinner = new Spinner(sprintf("Building %s (%d of %d) ...", $themeNameCyan, $currentTheme, $totalThemes));
134+
$success = false;
135+
136+
$spinner->spin(function() use ($themeCode, $io, $output, $isVerbose, &$successList, &$success) {
137+
$success = $this->processTheme($themeCode, $io, $output, $isVerbose, $successList);
138+
return true;
139+
});
140+
141+
if ($success) {
142+
// Show that the theme was successfully built
143+
$io->writeln(sprintf(" Building %s (%d of %d) ... <fg=green>done</>", $themeNameCyan, $currentTheme, $totalThemes));
144+
} else {
145+
// Show that an error occurred while building the theme
146+
$io->writeln(sprintf(" Building %s (%d of %d) ... <fg=red>failed</>", $themeNameCyan, $currentTheme, $totalThemes));
134147
}
135-
return true;
136-
});
148+
}
137149
}
138150

139151
$this->displayBuildSummary($io, $successList, microtime(true) - $startTime);
@@ -195,18 +207,38 @@ private function processTheme(
195207
*/
196208
private function displayBuildSummary(SymfonyStyle $io, array $successList, float $duration): void
197209
{
210+
$io->newLine();
211+
$io->success(sprintf(
212+
"🚀 Build process completed in %.2f seconds with the following results:",
213+
$duration
214+
));
215+
$io->writeln("Summary:");
216+
$io->newLine();
217+
198218
if (empty($successList)) {
199219
$io->warning('No themes were built successfully.');
200220
return;
201221
}
202222

203-
$io->success(sprintf(
204-
"Build process completed in %.2f seconds with the following results:",
205-
$duration
206-
));
207-
208223
foreach ($successList as $success) {
209-
$io->writeln("$success");
224+
$parts = explode(': ', $success, 2);
225+
if (count($parts) === 2) {
226+
$themeName = $parts[0];
227+
$details = $parts[1];
228+
// Color the builder name in magenta
229+
if (preg_match('/(using\s+)([^\s]+)(\s+builder)/', $details, $matches)) {
230+
$details = str_replace(
231+
$matches[0],
232+
$matches[1] . '<fg=magenta>' . $matches[2] . '</>' . $matches[3],
233+
$details
234+
);
235+
}
236+
$io->writeln(sprintf("✅ <fg=cyan>%s</>: %s", $themeName, $details));
237+
} else {
238+
$io->writeln("$success");
239+
}
210240
}
241+
242+
$io->newLine();
211243
}
212244
}

0 commit comments

Comments
 (0)