1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 08:24: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 Closure;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Process;
class Install extends Command class Install extends Command
{ {
@ -128,14 +129,27 @@ class Install extends Command
public function askForSupport(): void public function askForSupport(): void
{ {
if ($this->components->confirm('Would you like to show your support by starring the project on GitHub?', true)) { if ($this->components->confirm('Would you like to show your support by starring the project on GitHub?', true)) {
if (PHP_OS_FAMILY === 'Darwin') { $ghVersion = Process::run('gh --version');
exec('open https://github.com/archtechx/tenancy'); $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 (PHP_OS_FAMILY === 'Windows') {
exec('start https://github.com/archtechx/tenancy'); if ($starred) {
} $this->components->success('Repository starred via gh CLI, thank you!');
if (PHP_OS_FAMILY === 'Linux') { } else {
exec('xdg-open https://github.com/archtechx/tenancy'); if (PHP_OS_FAMILY === 'Darwin') {
exec('open https://github.com/archtechx/tenancy');
}
if (PHP_OS_FAMILY === 'Windows') {
exec('start https://github.com/archtechx/tenancy');
}
if (PHP_OS_FAMILY === 'Linux') {
exec('xdg-open https://github.com/archtechx/tenancy');
}
} }
} }
} }