1313use Tempest \Console \HasConsole ;
1414use Tempest \Container \Container ;
1515use Tempest \Container \GenericContainer ;
16+ use Tempest \Core \AppConfig ;
17+ use Tempest \Core \ConfigCache ;
1618use Tempest \Core \DiscoveryCache ;
1719use Tempest \Support \Str ;
1820use Tempest \View \IconCache ;
2830 public function __construct (
2931 private Console $ console ,
3032 private Container $ container ,
33+ private AppConfig $ appConfig ,
34+ private DiscoveryCache $ discoveryCache ,
3135 ) {}
3236
3337 #[ConsoleCommand(name: 'cache:status ' , description: 'Shows which caches are enabled ' )]
@@ -45,7 +49,7 @@ public function __invoke(bool $internal = true): void
4549 if ($ internal ) {
4650 $ this ->console ->header ('Internal caches ' );
4751
48- foreach ([ViewCache ::class, IconCache ::class, DiscoveryCache ::class] as $ cacheName ) {
52+ foreach ([ConfigCache ::class, ViewCache ::class, IconCache ::class] as $ cacheName ) {
4953 /** @var Cache $cache */
5054 $ cache = $ this ->container ->get ($ cacheName );
5155
@@ -57,6 +61,22 @@ public function __invoke(bool $internal = true): void
5761 },
5862 );
5963 }
64+
65+ $ this ->console ->keyValue (
66+ key: DiscoveryCache::class,
67+ value: match ($ this ->discoveryCache ->valid ) {
68+ false => '<style="bold fg-red">INVALID</style> ' ,
69+ true => match ($ this ->discoveryCache ->enabled ) {
70+ true => '<style="bold fg-green">ENABLED</style> ' ,
71+ false => '<style="bold fg-red">DISABLED</style> ' ,
72+ },
73+ },
74+ );
75+
76+ if ($ this ->appConfig ->environment ->isProduction () && ! $ this ->discoveryCache ->enabled ) {
77+ $ this ->console ->writeln ();
78+ $ this ->console ->error ('Discovery cache is disabled in production. This is not recommended. ' );
79+ }
6080 }
6181
6282 $ this ->console ->header ('User caches ' );
0 commit comments