2
2
3
3
namespace ProjektGopher \Whisky \Commands ;
4
4
5
+ use Illuminate \Support \Facades \Process ;
5
6
use LaravelZero \Framework \Commands \Command ;
6
7
use ProjektGopher \Whisky \Platform ;
7
8
use ProjektGopher \Whisky \Whisky ;
@@ -14,26 +15,16 @@ class Audit extends Command
14
15
15
16
public function handle (): int
16
17
{
17
- // co-pilot things. Might be useful, might not.
18
- // $this->table(
19
- // ['Hook', 'Status', 'File', 'Scripts'],
20
- // Hook::all()->map(function (Hook $hook): array {
21
- // return [
22
- // $hook->name,
23
- // $hook->status(),
24
- // $hook->file(),
25
- // $hook->scripts()->implode(PHP_EOL),
26
- // ];
27
- // })->toArray()
28
- // );
29
18
$ platform = new Platform ();
30
19
31
20
$ this ->table (
32
21
['key ' , 'value ' ],
33
22
[
34
23
['- Whisky - ' , '' ],
35
- ['installed globally? ' , Whisky:: isInstalledGlobally () ? ' yes ' : ' no ' ],
24
+ ['installed globally? ' , $ this -> isWhiskyInstalledGlobally () ],
36
25
['running globally? ' , Whisky::isRunningGlobally () ? 'yes ' : 'no ' ],
26
+ ['installed locally? ' , $ this ->isWhiskyInstalledLocally ()],
27
+ ['running locally? ' , Whisky::isRunningLocally () ? 'yes ' : 'no ' ],
37
28
['dogfooding? ' , Whisky::dogfooding () ? 'yes ' : 'no ' ],
38
29
['base path ' , Whisky::base_path ()],
39
30
['bin path ' , Whisky::bin_path ()],
@@ -54,4 +45,28 @@ public function handle(): int
54
45
55
46
return Command::SUCCESS ;
56
47
}
48
+
49
+ protected function isWhiskyInstalledGlobally (): string
50
+ {
51
+ if (! Whisky::isInstalledGlobally ()) {
52
+ return 'no ' ;
53
+ }
54
+
55
+ $ result = Process::run ('composer global show projektgopher/whisky --format=json ' );
56
+ $ version = json_decode ($ result ->output (), true )['versions ' ][0 ];
57
+
58
+ return "yes ( {$ version }) " ;
59
+ }
60
+
61
+ protected function isWhiskyInstalledLocally (): string
62
+ {
63
+ if (! Whisky::isInstalledLocally ()) {
64
+ return 'no ' ;
65
+ }
66
+
67
+ $ result = Process::run ('composer show projektgopher/whisky --format=json ' );
68
+ $ version = json_decode ($ result ->output (), true )['versions ' ][0 ];
69
+
70
+ return "yes ( {$ version }) " ;
71
+ }
57
72
}
0 commit comments