1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 06:44:04 +00:00

install: support starring using GH CLI

This commit is contained in:
Samuel Štancl 2025-09-26 13:41:43 +02:00
parent b320f8f33d
commit 3846fe88ec

View file

@ -6,6 +6,7 @@ namespace Stancl\Tenancy\Commands;
use Closure;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Process;
class Install extends Command
{
@ -128,6 +129,18 @@ class Install extends Command
public function askForSupport(): void
{
if ($this->components->confirm('Would you like to show your support by starring the project on GitHub?', true)) {
$ghVersion = Process::run('gh --version');
$starred = false;
// Make sure the `gh` binary is the actual GitHub CLI and not an unrelated tool
if ($ghVersion->successful() && str_contains($ghVersion->output(), 'https://github.com/cli/cli')) {
$starRequest = Process::run('gh api -X PUT user/starred/archtechx/tenancy');
$starred = $starRequest->successful();
}
if ($starred) {
$this->components->success('Repository starred via gh CLI, thank you!');
} else {
if (PHP_OS_FAMILY === 'Darwin') {
exec('open https://github.com/archtechx/tenancy');
}
@ -140,3 +153,4 @@ class Install extends Command
}
}
}
}