diff --git a/CHANGELOG.md b/CHANGELOG.md index 10497ad..6cf48da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,13 @@ All notable changes to this project will be documented in this file. ## UNRELEASED - ### Added +- feat: add verbose output support for watch task with `-v` flag + - Shows informative messages during watch mode based on verbosity level + - Captures and reports exit codes from npm/grunt watch commands + - Displays clear error messages when watch mode exits with errors + - Provides hint to use `-v` flag for verbose output in non-verbose mode - feat: add `mageforge:theme:tokens` command to generate Hyvä design tokens from design.tokens.json or hyva.config.json - feat: add `mageforge:hyva:compatibility:check` command to add a Hyvä compatibility checker - Scans Magento modules for Hyvä theme compatibility issues @@ -26,8 +30,15 @@ All notable changes to this project will be documented in this file. - feat: add command alias `frontend:clean` for quick access - feat: add CI/CD tests for static:clean command in compatibility workflow +### Fixed + +- fix: remove duplicate `--verbose` option from WatchCommand that conflicted with Symfony Console's built-in verbose option + ### Changed +- refactor: improve build commands to show full output in verbose mode + - Remove `--quiet` flag from npm/grunt build commands when using verbose mode + - Allow better debugging of build issues during theme compilation - refactor: split complex executeCommand method into smaller, focused methods to reduce cyclomatic complexity - docs: update copilot-instructions.md with CI/CD integration guidelines for new commands diff --git a/src/Console/Command/Theme/WatchCommand.php b/src/Console/Command/Theme/WatchCommand.php index 258d4f1..9afcee1 100644 --- a/src/Console/Command/Theme/WatchCommand.php +++ b/src/Console/Command/Theme/WatchCommand.php @@ -59,6 +59,7 @@ protected function configure() protected function executeCommand(InputInterface $input, OutputInterface $output): int { $themeCode = $input->getArgument('themeCode'); + $isVerbose = $this->isVerbose($output); if (empty($themeCode)) { $themeCode = $input->getOption('theme'); @@ -89,6 +90,6 @@ protected function executeCommand(InputInterface $input, OutputInterface $output } $builder = $this->builderPool->getBuilder($themePath); - return $builder->watch($themePath, $this->io, $output, true) ? self::SUCCESS : self::FAILURE; + return $builder->watch($themePath, $this->io, $output, $isVerbose) ? self::SUCCESS : self::FAILURE; } } diff --git a/src/Service/ThemeBuilder/HyvaThemes/Builder.php b/src/Service/ThemeBuilder/HyvaThemes/Builder.php index 7bc5f33..b3d8b9d 100644 --- a/src/Service/ThemeBuilder/HyvaThemes/Builder.php +++ b/src/Service/ThemeBuilder/HyvaThemes/Builder.php @@ -121,7 +121,9 @@ private function buildTheme(string $themePath, SymfonyStyle $io, bool $isVerbose if ($isVerbose) { $io->text('Running npm build...'); } - $this->shell->execute('npm run build --quiet'); + // Use --quiet only in non-verbose mode to suppress routine output + $buildCommand = $isVerbose ? 'npm run build' : 'npm run build --quiet'; + $this->shell->execute($buildCommand); if ($isVerbose) { $io->success('Hyvä theme build completed successfully.'); } @@ -226,8 +228,21 @@ public function watch(string $themePath, SymfonyStyle $io, OutputInterface $outp } try { + if ($isVerbose) { + $io->text('Starting watch mode with verbose output...'); + } else { + $io->text('Starting watch mode... (use -v for verbose output)'); + } + chdir($tailwindPath); - passthru('npm run watch'); + $exitCode = 0; + passthru('npm run watch', $exitCode); + + // Check if the command failed + if ($exitCode !== 0) { + $io->error(sprintf('Watch mode exited with error code: %d', $exitCode)); + return false; + } } catch (\Exception $e) { $io->error('Failed to start watch mode: ' . $e->getMessage()); return false; diff --git a/src/Service/ThemeBuilder/MagentoStandard/Builder.php b/src/Service/ThemeBuilder/MagentoStandard/Builder.php index 2b81156..be2d83d 100644 --- a/src/Service/ThemeBuilder/MagentoStandard/Builder.php +++ b/src/Service/ThemeBuilder/MagentoStandard/Builder.php @@ -49,13 +49,17 @@ public function build(string $themePath, SymfonyStyle $io, OutputInterface $outp try { if ($isVerbose) { $io->text('Running grunt clean...'); + $this->shell->execute('node_modules/.bin/grunt clean'); + } else { + $this->shell->execute('node_modules/.bin/grunt clean --quiet'); } - $this->shell->execute('node_modules/.bin/grunt clean --quiet'); if ($isVerbose) { $io->text('Running grunt less...'); + $this->shell->execute('node_modules/.bin/grunt less'); + } else { + $this->shell->execute('node_modules/.bin/grunt less --quiet'); } - $this->shell->execute('node_modules/.bin/grunt less --quiet'); if ($isVerbose) { $io->success('Grunt tasks completed successfully.'); @@ -193,7 +197,20 @@ public function watch(string $themePath, SymfonyStyle $io, OutputInterface $outp } try { - passthru('node_modules/.bin/grunt watch'); + if ($isVerbose) { + $io->text('Starting watch mode with verbose output...'); + } else { + $io->text('Starting watch mode... (use -v for verbose output)'); + } + + $exitCode = 0; + passthru('node_modules/.bin/grunt watch', $exitCode); + + // Check if the command failed + if ($exitCode !== 0) { + $io->error(sprintf('Watch mode exited with error code: %d', $exitCode)); + return false; + } } catch (\Exception $e) { $io->error('Failed to start watch mode: ' . $e->getMessage()); return false; diff --git a/src/Service/ThemeBuilder/TailwindCSS/Builder.php b/src/Service/ThemeBuilder/TailwindCSS/Builder.php index 3e03a7e..5b8c27d 100644 --- a/src/Service/ThemeBuilder/TailwindCSS/Builder.php +++ b/src/Service/ThemeBuilder/TailwindCSS/Builder.php @@ -79,7 +79,9 @@ public function build(string $themePath, SymfonyStyle $io, OutputInterface $outp if ($isVerbose) { $io->text('Running npm build...'); } - $this->shell->execute('npm run build --quiet'); + // Use --quiet only in non-verbose mode to suppress routine output + $buildCommand = $isVerbose ? 'npm run build' : 'npm run build --quiet'; + $this->shell->execute($buildCommand); if ($isVerbose) { $io->success('Custom TailwindCSS theme build completed successfully.'); } @@ -198,8 +200,21 @@ public function watch(string $themePath, SymfonyStyle $io, OutputInterface $outp } try { + if ($isVerbose) { + $io->text('Starting watch mode with verbose output...'); + } else { + $io->text('Starting watch mode... (use -v for verbose output)'); + } + chdir($tailwindPath); - passthru('npm run watch'); + $exitCode = 0; + passthru('npm run watch', $exitCode); + + // Check if the command failed + if ($exitCode !== 0) { + $io->error(sprintf('Watch mode exited with error code: %d', $exitCode)); + return false; + } } catch (\Exception $e) { $io->error('Failed to start watch mode: ' . $e->getMessage()); return false;