-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathSatisBuild.php
More file actions
77 lines (59 loc) · 2.07 KB
/
SatisBuild.php
File metadata and controls
77 lines (59 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace App\Console\Commands;
use App\Models\Plugin;
use App\Services\SatisService;
use Illuminate\Console\Command;
class SatisBuild extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'satis:build
{--plugin= : Build only a specific plugin by name (e.g., vendor/package)}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Trigger a Satis repository build';
/**
* Execute the console command.
*/
public function handle(SatisService $satisService): int
{
$pluginName = $this->option('plugin');
if ($pluginName) {
$plugin = Plugin::where('name', $pluginName)->first();
if (! $plugin) {
$this->error("Plugin '{$pluginName}' not found.");
return self::FAILURE;
}
if (! $plugin->isApproved()) {
$this->error("Plugin '{$pluginName}' is not approved.");
return self::FAILURE;
}
$this->info("Triggering Satis build for: {$pluginName}");
$result = $satisService->build([$plugin]);
} else {
$this->info('Triggering Satis build for all approved plugins...');
$result = $satisService->buildAll();
}
if ($result['success']) {
$this->info('Build triggered successfully!');
$this->line("Job ID: {$result['job_id']}");
if (isset($result['plugins_count'])) {
$this->line("Plugins: {$result['plugins_count']}");
}
return self::SUCCESS;
}
$this->error('Build trigger failed: '.$result['error']);
if (isset($result['status'])) {
$this->line("HTTP Status: {$result['status']}");
}
$this->line('API URL: '.config('services.satis.url'));
$this->line('API Key configured: '.(config('services.satis.api_key') ? 'Yes' : 'No'));
return self::FAILURE;
}
}