Skip to content

Commit b2be39d

Browse files
simonhampclaude
andauthored
Filter satis:build to only include paid plugins (#280)
* Filter satis:build to only include paid plugins The buildAll command was including all approved plugins (both free and paid) in satis builds. This filters getApprovedPlugins() to only return paid plugins, since free plugins don't need private Composer repository distribution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add full_build flag to satis API request for buildAll When buildAll() is called (no explicit plugin names), the API request now includes full_build: true so the satis server knows to perform a complete rebuild rather than a partial one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d65ef9c commit b2be39d

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

app/Services/SatisService.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Services;
44

5+
use App\Enums\PluginType;
56
use App\Models\Plugin;
67
use Illuminate\Support\Facades\Http;
78
use Illuminate\Support\Facades\Log;
@@ -25,7 +26,7 @@ public function buildAll(?string $githubToken = null): array
2526
{
2627
$plugins = $this->getApprovedPlugins();
2728

28-
return $this->triggerBuild($plugins, $githubToken);
29+
return $this->triggerBuild($plugins, $githubToken, fullBuild: true);
2930
}
3031

3132
/**
@@ -107,6 +108,7 @@ protected function getApprovedPlugins(): array
107108
{
108109
return Plugin::query()
109110
->approved()
111+
->where('type', PluginType::Paid)
110112
->get()
111113
->map(fn (Plugin $plugin) => [
112114
'name' => $plugin->name,
@@ -120,7 +122,7 @@ protected function getApprovedPlugins(): array
120122
/**
121123
* @param array<int, array{name: string, repository_url: string, type: string, is_official?: bool}> $plugins
122124
*/
123-
protected function triggerBuild(array $plugins, ?string $githubToken = null): array
125+
protected function triggerBuild(array $plugins, ?string $githubToken = null, bool $fullBuild = false): array
124126
{
125127
if (! $this->apiUrl || ! $this->apiKey) {
126128
return [
@@ -139,7 +141,10 @@ protected function triggerBuild(array $plugins, ?string $githubToken = null): ar
139141
$githubToken ??= config('services.github.token');
140142

141143
try {
142-
$payload = ['plugins' => $plugins];
144+
$payload = [
145+
'plugins' => $plugins,
146+
'full_build' => $fullBuild,
147+
];
143148

144149
if ($githubToken) {
145150
$payload['github_token'] = $githubToken;

tests/Feature/SatisSync/SatisSyncTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use App\Services\SatisService;
1010
use Illuminate\Foundation\Testing\RefreshDatabase;
1111
use Illuminate\Support\Facades\Bus;
12+
use Illuminate\Support\Facades\Http;
1213
use Livewire\Livewire;
1314
use Tests\TestCase;
1415

@@ -124,4 +125,29 @@ public function test_is_satis_synced_returns_true_when_synced(): void
124125

125126
$this->assertTrue($plugin->isSatisSynced());
126127
}
128+
129+
public function test_build_all_only_includes_paid_plugins(): void
130+
{
131+
Http::fake(['*' => Http::response(['job_id' => 'test-123', 'message' => 'Build started'], 200)]);
132+
133+
config(['services.satis.url' => 'https://satis.test', 'services.satis.api_key' => 'test-key']);
134+
135+
$paidPlugin = Plugin::factory()->paid()->approved()->create();
136+
Plugin::factory()->free()->approved()->create();
137+
138+
$service = new SatisService;
139+
$result = $service->buildAll();
140+
141+
$this->assertTrue($result['success']);
142+
$this->assertEquals(1, $result['plugins_count']);
143+
144+
Http::assertSent(function ($request) use ($paidPlugin) {
145+
$data = $request->data();
146+
$plugins = $data['plugins'] ?? [];
147+
148+
return count($plugins) === 1
149+
&& $plugins[0]['name'] === $paidPlugin->name
150+
&& $data['full_build'] === true;
151+
});
152+
}
127153
}

0 commit comments

Comments
 (0)