@@ -25,7 +25,9 @@ class CliTest extends Command
2525 * @param ThemeList $themeList
2626 */
2727 public function __construct (
28+ private readonly ThemePath $ themePath ,
2829 private readonly ThemeList $ themeList ,
30+ private readonly BuilderPool $ builderPool
2931 ) {
3032 parent ::__construct ();
3133 }
@@ -43,68 +45,74 @@ protected function configure(): void
4345 }
4446 protected function execute (InputInterface $ input , OutputInterface $ output ): int
4547 {
46- for ($ i = 5 ; $ i >= 1 ; $ i --) {
47- $ output ->writeln ('Start npm in ' . $ i );
48- sleep (1 );
49- }
50-
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- */
77- $ output ->writeln ('Running npm outdated... ' );
78- exec ('npm outdated ' , $ npmOutput , $ returnValue );
7948
80- if ($ returnValue !== 0 || !empty ($ npmOutput )) {
81- $ io = new SymfonyStyle ($ input , $ output );
82- $ io ->warning ('Outdated packages found! ' );
83- } else {
84- $ io = new SymfonyStyle ($ input , $ output );
85- $ io ->success ('No outdated packages found, proceeding with installation. ' );
86- }
87-
88- foreach ($ npmOutput as $ line ) {
89- $ output ->writeln ($ line );
90- }
91-
92- sleep (2 );
93- $ output ->writeln ('Running npm install... ' );
94- exec ('npm install ' , $ npmOutput , $ returnValue );
95- foreach ($ npmOutput as $ line ) {
96- $ output ->writeln ($ line );
97- }
98-
99- if ($ returnValue !== 0 ) {
100- $ io = new SymfonyStyle ($ input , $ output );
101- $ io ->error ('Npm install failed! ' );
49+ try {
50+ for ($ i = 5 ; $ i >= 1 ; $ i --) {
51+ $ output ->writeln ('Start npm in ' . $ i );
52+ sleep (1 );
53+ }
54+
55+ /**
56+ * list all available themes
57+ */
58+ $ themes = $ this ->themeList ->getAllThemes ();
59+ if (empty ($ themes )) {
60+ $ output ->writeln ('<info>No themes found.</info> ' );
61+ return Cli::RETURN_SUCCESS ;
62+ }
63+
64+ $ output ->writeln ('<info>Available Themes:</info> ' );
65+ $ table = new Table ($ output );
66+ $ table ->setHeaders (['Code ' , 'Title ' , 'Path ' ]);
67+
68+ foreach ($ themes as $ path => $ theme ) {
69+ $ table ->addRow ([
70+ sprintf ('<fg=yellow>%s</> ' , $ theme ->getCode ()),
71+ $ theme ->getThemeTitle (),
72+ $ path
73+ ]);
74+ }
75+
76+ $ table ->render ();
77+
78+ /**
79+ * Run NPM Outdated and NPM Install
80+ */
81+ $ output ->writeln ('Running npm outdated... ' );
82+ exec ('npm outdated ' , $ npmOutput , $ returnValue );
83+
84+ if ($ returnValue !== 0 || !empty ($ npmOutput )) {
85+ $ io = new SymfonyStyle ($ input , $ output );
86+ $ io ->warning ('Outdated packages found! ' );
87+ } else {
88+ $ io = new SymfonyStyle ($ input , $ output );
89+ $ io ->success ('No outdated packages found, proceeding with installation. ' );
90+ }
91+
92+ foreach ($ npmOutput as $ line ) {
93+ $ output ->writeln ($ line );
94+ }
95+
96+ sleep (2 );
97+ $ output ->writeln ('Running npm install... ' );
98+ exec ('npm install ' , $ npmOutput , $ returnValue );
99+ foreach ($ npmOutput as $ line ) {
100+ $ output ->writeln ($ line );
101+ }
102+
103+ if ($ returnValue !== 0 ) {
104+ $ io = new SymfonyStyle ($ input , $ output );
105+ $ io ->error ('Npm install failed! ' );
106+ return Command::FAILURE ;
107+ }
108+
109+ $ io ->success ('Npm install completed successfully. ' );
110+
111+ return Command::SUCCESS ;
112+ } catch (\Exception $ e ) {
113+ $ io ->error ($ e ->getMessage ());
102114 return Command::FAILURE ;
103115 }
104-
105- $ io ->success ('Npm install completed successfully. ' );
106-
107- return Command::SUCCESS ;
108116 }
109117
110118}
0 commit comments