@@ -22,6 +22,7 @@ protected function configure(): void
2222 ->addOption ('no-js ' , null , InputOption::VALUE_NONE , 'Disable JS compilation (core + plugins) ' )
2323 ->addOption ('no-twig ' , null , InputOption::VALUE_NONE , 'Disable Twig watch/live reload feedback ' )
2424 ->addOption ('no-scss ' , null , InputOption::VALUE_NONE , 'Disable SCSS compilation ' )
25+ ->addOption ('skip-theme-dump ' , null , InputOption::VALUE_NONE , 'Skip theme:dump before watcher startup ' )
2526 ->addOption ('open-browser ' , null , InputOption::VALUE_NONE , 'Auto-open browser on startup ' );
2627 }
2728
@@ -62,11 +63,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6263 $ disableJs = (bool ) $ input ->getOption ('no-js ' );
6364 $ disableTwig = (bool ) $ input ->getOption ('no-twig ' );
6465 $ disableScss = (bool ) $ input ->getOption ('no-scss ' );
66+ $ skipThemeDump = (bool ) $ input ->getOption ('skip-theme-dump ' );
6567 $ openBrowser = (bool ) $ input ->getOption ('open-browser ' );
6668 $ scssEngine = $ this ->resolveScssEngine ();
6769
68- if (!$ input ->isInteractive () || !Process::isTtySupported ()) {
69- $ io ->error ('sidworks:watch-storefront requires an interactive TTY terminal because theme selection is always prompted . ' );
70+ if (!$ skipThemeDump && (! $ input ->isInteractive () || !Process::isTtySupported () )) {
71+ $ io ->error ('sidworks:watch-storefront requires an interactive TTY terminal for theme selection. Use --skip-theme-dump to skip it . ' );
7072
7173 return self ::FAILURE ;
7274 }
@@ -90,7 +92,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9092 $ assetPort = (int ) ($ hotEnvironment ['STOREFRONT_ASSETS_PORT ' ] ?? 9999 ) ?: 9999 ;
9193 $ this ->killProcessesOnPorts ([$ proxyPort , $ assetPort ], $ io );
9294
93- $ this ->renderStartupOverview ($ io , $ projectRoot , $ packageManager , $ storefrontApp , $ hotProxyScript , $ hotEnvironment );
95+ $ this ->renderStartupOverview (
96+ $ io ,
97+ $ projectRoot ,
98+ $ packageManager ,
99+ $ storefrontApp ,
100+ $ hotProxyScript ,
101+ $ hotEnvironment ,
102+ $ skipThemeDump
103+ );
94104
95105 if (!is_dir ($ storefrontApp . '/node_modules/webpack-dev-server ' )) {
96106 $ io ->writeln ('Installing storefront dependencies ' );
@@ -112,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112122 }
113123 }
114124
115- $ prepExitCode = $ this ->runPrepCommands ($ output , $ input , $ projectRoot );
125+ $ prepExitCode = $ this ->runPrepCommands ($ output , $ input , $ projectRoot, $ skipThemeDump );
116126 if ($ prepExitCode !== 0 ) {
117127 return $ prepExitCode ;
118128 }
@@ -132,8 +142,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
132142 private function runPrepCommands (
133143 OutputInterface $ output ,
134144 InputInterface $ input ,
135- string $ projectRoot
145+ string $ projectRoot ,
146+ bool $ skipThemeDump
136147 ): int {
148+ if ($ skipThemeDump ) {
149+ return 0 ;
150+ }
151+
152+ $ themeCompileExitCode = $ this ->runConsoleCommand (['theme:compile ' , '--active-only ' ], $ projectRoot , $ output , $ input );
153+ if ($ themeCompileExitCode !== 0 ) {
154+ return $ themeCompileExitCode ;
155+ }
156+
137157 return $ this ->runConsoleCommand (['theme:dump ' ], $ projectRoot , $ output , $ input , false );
138158 }
139159
@@ -163,7 +183,8 @@ private function renderStartupOverview(
163183 string $ packageManager ,
164184 string $ storefrontApp ,
165185 string $ hotProxyScript ,
166- array $ hotEnvironment
186+ array $ hotEnvironment ,
187+ bool $ skipThemeDump
167188 ): void {
168189 $ disableJs = ($ hotEnvironment ['SHOPWARE_STOREFRONT_DISABLE_JS ' ] ?? '0 ' ) === '1 ' ;
169190 $ disableTwig = ($ hotEnvironment ['SHOPWARE_STOREFRONT_DISABLE_TWIG ' ] ?? '0 ' ) === '1 ' ;
@@ -173,35 +194,36 @@ private function renderStartupOverview(
173194 $ io ->title ('Sidworks Storefront Watcher ' );
174195
175196 $ io ->definitionList (
197+ ['Package manager ' => \sprintf ('<info>%s</info> ' , $ packageManager )],
176198 ['Storefront ' => \sprintf ('<comment>%s</comment> ' , $ this ->formatPathForDisplay ($ storefrontApp , $ projectRoot ))],
199+ ['Hot proxy runtime ' => \sprintf ('<comment>%s</comment> ' , $ this ->formatPathForDisplay ($ hotProxyScript , $ projectRoot ))],
177200 ['SCSS engine ' => \sprintf ('<info>%s</info> ' , $ scssEngine )],
178201 ['Parallelism ' => \sprintf ('<info>%s</info> cores ' , $ hotEnvironment ['SHOPWARE_BUILD_PARALLELISM ' ])],
179202 );
180203
181- $ flags = [];
182- if ($ disableJs ) {
183- $ flags [] = '<comment>JS disabled</comment> ' ;
184- }
185- if ($ disableTwig ) {
186- $ flags [] = '<comment>Twig disabled</comment> ' ;
187- }
188- if ($ disableScss ) {
189- $ flags [] = '<comment>SCSS disabled</comment> ' ;
190- }
191- if (($ hotEnvironment ['SHOPWARE_STOREFRONT_HOT_CORE_ONLY ' ] ?? '0 ' ) === '1 ' ) {
192- $ flags [] = '<comment>core-only mode</comment> ' ;
193- }
194- if (($ hotEnvironment ['SHOPWARE_STOREFRONT_JS_SOURCE_MAP ' ] ?? '0 ' ) === '1 ' ) {
195- $ flags [] = 'JS source maps ' ;
196- }
197- if (($ hotEnvironment ['SHOPWARE_STOREFRONT_SCSS_SOURCE_MAP ' ] ?? '0 ' ) === '1 ' ) {
198- $ flags [] = 'SCSS source maps ' ;
204+ $ io ->table (
205+ ['Option ' , 'State ' ],
206+ [
207+ ['Theme dump before start ' , $ this ->formatOnOff (!$ skipThemeDump , $ skipThemeDump ? '--skip-theme-dump ' : null )],
208+ ['JS compilation ' , $ this ->formatOnOff (!$ disableJs , $ disableJs ? '--no-js ' : null )],
209+ ['Twig watch ' , $ this ->formatOnOff (!$ disableTwig , $ disableTwig ? '--no-twig ' : null )],
210+ ['SCSS compilation ' , $ this ->formatOnOff (!$ disableScss , $ disableScss ? '--no-scss ' : null )],
211+ ['Auto-open browser ' , $ this ->formatOnOff (($ hotEnvironment ['SHOPWARE_STOREFRONT_OPEN_BROWSER ' ] ?? '0 ' ) === '1 ' )],
212+ ]
213+ );
214+ }
215+
216+ private function formatOnOff (bool $ enabled , ?string $ offReason = null ): string
217+ {
218+ if ($ enabled ) {
219+ return '<fg=green>[ON]</> ' ;
199220 }
200221
201- if ($ flags !== []) {
202- $ io ->writeln (\sprintf (' <info>Flags:</info> %s ' , implode (', ' , $ flags )));
203- $ io ->newLine ();
222+ if ($ offReason !== null && $ offReason !== '' ) {
223+ return \sprintf ('<fg=yellow>[OFF]</> <comment>(%s)</comment> ' , $ offReason );
204224 }
225+
226+ return '<fg=yellow>[OFF]</> ' ;
205227 }
206228
207229 private function runPackageInstall (
0 commit comments