Skip to content

Commit

Permalink
πŸ‘¨β€πŸ’» add about command (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t committed Feb 28, 2023
1 parent d94a60f commit 557ba93
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/Roots/Acorn/Console/Commands/AboutCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Roots\Acorn\Console\Commands;

use Illuminate\Foundation\Application as FoundationApplication;
use Illuminate\Foundation\Console\AboutCommand as BaseCommand;
use Illuminate\Support\Str;
use Roots\Acorn\Application;
use ReflectionFunction;

class AboutCommand extends BaseCommand
{
protected function gatherApplicationInformation()
{
parent::gatherApplicationInformation();

$this->aboutEnvironment();
}

/**
* Add environment information.
*/
protected function aboutEnvironment()
{
// Laravel does not provide an easy way to override a section
// so we have to unset it and then add it back, and then
// re-execute any custom environment resolvers.
unset(self::$data['Environment']);

static::addToSection('Environment', fn () => [
'Application Name' => $this->laravel->get('config')->get('app.name'),
'PHP' => $this->formatVersion(PHP_VERSION),
'Xdebug' => $this->formatVersion(phpversion('xdebug')),
'Composer' => $this->formatVersion($this->composer->getVersion()),
'Acorn' => $this->formatVersion(Application::VERSION),
'Laravel' => $this->formatVersion(FoundationApplication::VERSION),
'WordPress' => $this->formatVersion(get_bloginfo('version')),
'WP-CLI' => $this->formatVersion(defined('WP_CLI_VERSION') ? WP_CLI_VERSION : null),
'Environment' => $this->laravel->environment(),
'Debug Mode' => $this->laravel->get('config')->get('app.debug') ? '<fg=yellow;options=bold>ENABLED</>' : 'OFF',
'Maintenance Mode' => $this->laravel->isDownForMaintenance() ? '<fg=yellow;options=bold>ENABLED</>' : 'OFF',
'URL' => Str::of(config('app.url'))->replace(['http://', 'https://'], ''),
'Plugins' => count(get_site_transient('update_plugins')->response) ? '<fg=yellow;options=bold>UPDATES AVAILABLE</>' : '<fg=green;options=bold>UP TO DATE</>',
'Themes' => count(get_site_transient('update_themes')->response) ? '<fg=yellow;options=bold>UPDATES AVAILABLE</>' : '<fg=green;options=bold>UP TO DATE</>',
]);

collect(static::$customDataResolvers)
->filter('is_callable')
->filter(fn ($resolver) => (new ReflectionFunction($resolver))->getClosureUsedVariables()['section'] === 'Environment')
->each->__invoke();
}

protected function formatVersion($version)
{
return $version ? ('v' . ltrim($version, 'vV')) : '<fg=yellow;options=bold>-</>';
}
}
1 change: 1 addition & 0 deletions src/Roots/Acorn/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Kernel extends FoundationConsoleKernel
\Illuminate\Foundation\Console\ViewClearCommand::class,
\Illuminate\Routing\Console\ControllerMakeCommand::class,
\Illuminate\Routing\Console\MiddlewareMakeCommand::class,
\Roots\Acorn\Console\Commands\AboutCommand::class,
\Roots\Acorn\Console\Commands\AcornInitCommand::class,
\Roots\Acorn\Console\Commands\ComposerMakeCommand::class,
\Roots\Acorn\Console\Commands\ConfigCacheCommand::class,
Expand Down

0 comments on commit 557ba93

Please sign in to comment.