Skip to content

Commit

Permalink
[ Feat ] Audit command (hidden) (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjektGopher authored Aug 10, 2023
1 parent c19a69f commit 8091b0e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-
- name: Install composer dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Print Audit Data
run: php whisky audit
- name: Run tests
run: php whisky test
57 changes: 57 additions & 0 deletions app/Commands/Audit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace ProjektGopher\Whisky\Commands;

use LaravelZero\Framework\Commands\Command;
use ProjektGopher\Whisky\Platform;
use ProjektGopher\Whisky\Whisky;

class Audit extends Command
{
protected $signature = 'audit';

protected $description = 'Print table with information for diagnostic purposes.';

public function handle(): int
{
// co-pilot things. Might be useful, might not.
// $this->table(
// ['Hook', 'Status', 'File', 'Scripts'],
// Hook::all()->map(function (Hook $hook): array {
// return [
// $hook->name,
// $hook->status(),
// $hook->file(),
// $hook->scripts()->implode(PHP_EOL),
// ];
// })->toArray()
// );
$platform = new Platform();

$this->table(
['key', 'value'],
[
['- Whisky -', ''],
['installed globally?', Whisky::isInstalledGlobally() ? 'yes' : 'no'],
['running globally?', Whisky::isRunningGlobally() ? 'yes' : 'no'],
['dogfooding?', Whisky::dogfooding() ? 'yes' : 'no'],
['base path', Whisky::base_path()],
['bin path', Whisky::bin_path()],
// ['readConfig?', Whisky::readConfig()],
['- Platform -', ''],
['cwd', Platform::cwd()],
['getGlobalComposerHome', Platform::getGlobalComposerHome()],
['getGlobalComposerBinDir', Platform::getGlobalComposerBinDir()],
['isWindows', $platform->isWindows() ? 'yes' : 'no'],
['isNotWindows', $platform->isNotWindows() ? 'yes' : 'no'],
['gitIsInitialized', $platform->gitIsInitialized() ? 'yes' : 'no'],
['gitIsNotInitialized', $platform->gitIsNotInitialized() ? 'yes' : 'no'],
['- global -', ''],
['base_path', base_path()],
['normalized base_path', Platform::normalizePath(base_path())],
],
);

return Command::SUCCESS;
}
}
1 change: 1 addition & 0 deletions config/commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
Illuminate\Foundation\Console\VendorPublishCommand::class,
LaravelZero\Framework\Commands\StubPublishCommand::class,

Commands\Audit::class,
Commands\GetRunCmd::class,
],

Expand Down

0 comments on commit 8091b0e

Please sign in to comment.