Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/Console/Command/Theme/WatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}
}
19 changes: 17 additions & 2 deletions src/Service/ThemeBuilder/HyvaThemes/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 20 additions & 3 deletions src/Service/ThemeBuilder/MagentoStandard/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 17 additions & 2 deletions src/Service/ThemeBuilder/TailwindCSS/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down Expand Up @@ -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;
Expand Down