@fleetbase/registry-bridge-engine 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Console/Commands/Initialize.php +2 -2
- package/server/src/Http/Controllers/Internal/v1/RegistryExtensionController.php +6 -3
- package/server/src/Providers/RegistryBridgeServiceProvider.php +0 -1
- package/server/src/Console/Commands/PostInstallExtension.php +0 -84
package/composer.json
CHANGED
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\RegistryBridge\Console\Commands;
|
|
4
4
|
|
|
5
|
-
use Fleetbase\RegistryBridge\
|
|
5
|
+
use Fleetbase\RegistryBridge\Support\Utils;
|
|
6
6
|
use Illuminate\Console\Command;
|
|
7
7
|
|
|
8
8
|
class Initialize extends Command
|
|
@@ -28,7 +28,7 @@ class Initialize extends Command
|
|
|
28
28
|
*/
|
|
29
29
|
public function handle()
|
|
30
30
|
{
|
|
31
|
-
|
|
31
|
+
Utils::bootRegistryAuth(true);
|
|
32
32
|
|
|
33
33
|
return 0;
|
|
34
34
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\RegistryBridge\Http\Controllers\Internal\v1;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Exceptions\FleetbaseRequestValidationException;
|
|
6
|
+
use Fleetbase\Http\Requests\AdminRequest;
|
|
6
7
|
use Fleetbase\Models\Setting;
|
|
7
8
|
use Fleetbase\RegistryBridge\Http\Controllers\RegistryBridgeController;
|
|
8
9
|
use Fleetbase\RegistryBridge\Http\Requests\CreateRegistryExtensionRequest;
|
|
@@ -262,9 +263,11 @@ class RegistryExtensionController extends RegistryBridgeController
|
|
|
262
263
|
* This method fetches the current registry host and token from the configuration
|
|
263
264
|
* settings or environment variables and returns them in a JSON response.
|
|
264
265
|
*
|
|
266
|
+
* @param AdminRequest $request the incoming HTTP request containing the new host and token
|
|
267
|
+
*
|
|
265
268
|
* @return \Illuminate\Http\JsonResponse a JSON response containing the registry host and token
|
|
266
269
|
*/
|
|
267
|
-
public function getConfig()
|
|
270
|
+
public function getConfig(AdminRequest $request)
|
|
268
271
|
{
|
|
269
272
|
$registryHost = config('registry-bridge.registry.host', env('REGISTRY_HOST', 'https://registry.fleetbase.io'));
|
|
270
273
|
$registryToken = config('registry-bridge.registry.token', env('REGISTRY_TOKEN'));
|
|
@@ -282,11 +285,11 @@ class RegistryExtensionController extends RegistryBridgeController
|
|
|
282
285
|
* If no input is provided, it uses the current configuration values or environment variables.
|
|
283
286
|
* The updated configuration is then saved in the settings and returned in a JSON response.
|
|
284
287
|
*
|
|
285
|
-
* @param
|
|
288
|
+
* @param AdminRequest $request the incoming HTTP request containing the new host and token
|
|
286
289
|
*
|
|
287
290
|
* @return \Illuminate\Http\JsonResponse a JSON response containing the updated registry host and token
|
|
288
291
|
*/
|
|
289
|
-
public function saveConfig(
|
|
292
|
+
public function saveConfig(AdminRequest $request)
|
|
290
293
|
{
|
|
291
294
|
$currentRegistryHost = config('registry-bridge.registry.host', env('REGISTRY_HOST', 'https://registry.fleetbase.io'));
|
|
292
295
|
$currentRegistryToken = config('registry-bridge.registry.token', env('REGISTRY_TOKEN'));
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace Fleetbase\RegistryBridge\Console\Commands;
|
|
4
|
-
|
|
5
|
-
use Fleetbase\RegistryBridge\Models\RegistryExtension;
|
|
6
|
-
use Illuminate\Console\Command;
|
|
7
|
-
use Symfony\Component\Process\Exception\ProcessFailedException;
|
|
8
|
-
use Symfony\Component\Process\Process;
|
|
9
|
-
|
|
10
|
-
class PostInstallExtension extends Command
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* The name and signature of the console command.
|
|
14
|
-
*
|
|
15
|
-
* @var string
|
|
16
|
-
*/
|
|
17
|
-
protected $signature = 'registry:post-install {extensionId}';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The console command description.
|
|
21
|
-
*
|
|
22
|
-
* @var string
|
|
23
|
-
*/
|
|
24
|
-
protected $description = 'Post install an extension by running necessary commands';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Execute the console command.
|
|
28
|
-
*
|
|
29
|
-
* @return int
|
|
30
|
-
*/
|
|
31
|
-
public function handle()
|
|
32
|
-
{
|
|
33
|
-
$extensionId = $this->argument('extensionId');
|
|
34
|
-
$extension = RegistryExtension::disableCache()->where('public_id', $extensionId)->first();
|
|
35
|
-
|
|
36
|
-
if ($extension) {
|
|
37
|
-
$this->postInstallExtension($extension);
|
|
38
|
-
$this->info('Post install commands executed successfully.');
|
|
39
|
-
} else {
|
|
40
|
-
$this->error('Extension not found.');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Post install extension commands.
|
|
48
|
-
*/
|
|
49
|
-
public function postInstallExtension(RegistryExtension $extension): void
|
|
50
|
-
{
|
|
51
|
-
if (isset($extension->currentBundle)) {
|
|
52
|
-
$composerJson = $extension->currentBundle->meta['composer.json'];
|
|
53
|
-
if ($composerJson) {
|
|
54
|
-
$extensionPath = base_path('vendor/' . $composerJson['name']);
|
|
55
|
-
|
|
56
|
-
$commands = [
|
|
57
|
-
'rm -rf /fleetbase/.pnpm-store',
|
|
58
|
-
'rm -rf node_modules',
|
|
59
|
-
'pnpm install',
|
|
60
|
-
'pnpm build',
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
$this->info('Running post install for: ' . $extension->name);
|
|
64
|
-
$this->info('Extension install path: ' . $extensionPath);
|
|
65
|
-
foreach ($commands as $command) {
|
|
66
|
-
$this->info('Running extension post install command: `' . $command . '`');
|
|
67
|
-
$process = Process::fromShellCommandline($command, $extensionPath);
|
|
68
|
-
$process->run(function ($type, $buffer) {
|
|
69
|
-
if (Process::ERR === $type) {
|
|
70
|
-
$this->error($buffer);
|
|
71
|
-
} else {
|
|
72
|
-
$this->info($buffer);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Check if the process was successful
|
|
77
|
-
if (!$process->isSuccessful()) {
|
|
78
|
-
throw new ProcessFailedException($process);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|