Skip to content

Commit bfa08de

Browse files
committed
feat: add theme listing and npm commands to CliTest
1 parent 9bbec97 commit bfa08de

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/Console/Command/CliTest.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818

1919
class CliTest extends Command
2020
{
21+
22+
/**
23+
* Constructor
24+
*
25+
* @param ThemeList $themeList
26+
*/
27+
public function __construct(
28+
private readonly ThemeList $themeList,
29+
) {
30+
parent::__construct();
31+
}
32+
2133
protected function configure(): void
2234
{
2335
$this->setName('mageforge:system:clitest')
@@ -29,14 +41,39 @@ protected function configure(): void
2941
)
3042
->setAliases(['frontend:test']);
3143
}
32-
3344
protected function execute(InputInterface $input, OutputInterface $output): int
3445
{
3546
for ($i = 5; $i >= 1; $i--) {
3647
$output->writeln('Start npm in ' . $i);
3748
sleep(1);
3849
}
3950

51+
/**
52+
* list all available themes
53+
*/
54+
$themes = $this->themeList->getAllThemes();
55+
if (empty($themes)) {
56+
$output->writeln('<info>No themes found.</info>');
57+
return Cli::RETURN_SUCCESS;
58+
}
59+
60+
$output->writeln('<info>Available Themes:</info>');
61+
$table = new Table($output);
62+
$table->setHeaders(['Code', 'Title', 'Path']);
63+
64+
foreach ($themes as $path => $theme) {
65+
$table->addRow([
66+
sprintf('<fg=yellow>%s</>', $theme->getCode()),
67+
$theme->getThemeTitle(),
68+
$path
69+
]);
70+
}
71+
72+
$table->render();
73+
74+
/**
75+
* Run NPM Outdated and NPM Install
76+
*/
4077
$output->writeln('Running npm outdated...');
4178
exec('npm outdated', $npmOutput, $returnValue);
4279

@@ -53,7 +90,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5390
}
5491

5592
sleep(2);
56-
5793
$output->writeln('Running npm install...');
5894
exec('npm install', $npmOutput, $returnValue);
5995
foreach ($npmOutput as $line) {

0 commit comments

Comments
 (0)