From b3182a83695a0ce17fee73b84296ec10ae2f57dc Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 11 Apr 2025 07:12:46 -0600 Subject: [PATCH 1/4] fix: extensions doing what they're documented to do (as well as replacement methods for current behavior) --- .../ExtensionLibrary/BlueprintBaseLibrary.php | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php b/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php index f083ca4b..6ff693d3 100644 --- a/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php +++ b/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php @@ -228,6 +228,41 @@ public function extension(string $identifier): bool return str_contains($this->fileRead(base_path('.blueprint/extensions/blueprint/private/db/installed_extensions')), $identifier); } + /** + * Retrieves a list of installed extensions. + * + * This method reads a file containing a comma-separated list of installed + * extensions, parses it into an array, and returns the result. + * + * @return array An array of installed extensions. + */ + public function extensions(): Array + { + $array = explode(',', $this->fileRead(base_path('.blueprint/extensions/blueprint/private/db/installed_extensions'))); + return $array; + } + + /** + * Retrieves the configuration for a specified extension. + * + * This method checks if the given extension exists and, if so, reads its + * configuration file in YAML format. The configuration data is then filtered + * to remove any empty or falsy keys. + * + * @param string $extension The name of the extension to retrieve the configuration for. + * + * @return array|null The configuration array for the extension, or null if the extension does not exist. + */ + public function extensionConfig(string $extension): ?array + { + if(!$this->extension($extension)) { + return null; + } + $conf = Yaml::parse($this->fileRead(base_path(".blueprint/extensions/$extension/private/.store/conf.yml"))); + $conf = array_filter($conf, fn ($k) => !!$k); + return $conf; + } + /** * Returns an array containing all installed extensions's identifiers. * @@ -235,7 +270,7 @@ public function extension(string $identifier): bool * * [BlueprintExtensionLibrary documentation](https://blueprint.zip/docs/?page=documentation/$blueprint) */ - public function extensions(): Collection + public function extensionsConfigs(): Collection { $array = explode(',', $this->fileRead(base_path('.blueprint/extensions/blueprint/private/db/installed_extensions'))); $collection = new Collection(); @@ -247,7 +282,7 @@ public function extensions(): Collection try { $conf = Yaml::parse($this->fileRead(base_path(".blueprint/extensions/$extension/private/.store/conf.yml"))); - $collection->push(array_filter($conf['info'], fn ($k) => !!$k)); + $collection->push(array_filter($conf, fn ($k) => !!$k)); } catch (\Exception $e) { } } From ffdde82935f98fceb37cb53cfc1b6f0299aca531 Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 11 Apr 2025 07:15:38 -0600 Subject: [PATCH 2/4] fix all (i think) dependencies on changed methods --- app/Services/Telemetry/BlueprintTelemetryCollectionService.php | 2 +- resources/views/admin/extensions.blade.php | 3 ++- routes/blueprint.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Services/Telemetry/BlueprintTelemetryCollectionService.php b/app/Services/Telemetry/BlueprintTelemetryCollectionService.php index b841b650..9a503908 100644 --- a/app/Services/Telemetry/BlueprintTelemetryCollectionService.php +++ b/app/Services/Telemetry/BlueprintTelemetryCollectionService.php @@ -77,7 +77,7 @@ public function collect(): array 'blueprint' => [ 'version' => $this->placeholderService->version(), - 'extensions' => $this->blueprint->extensions()->toArray(), + 'extensions' => $this->blueprint->extensions(), 'flags' => $flags, 'docker' => file_exists('/.dockerenv'), ], diff --git a/resources/views/admin/extensions.blade.php b/resources/views/admin/extensions.blade.php index a4e49aaf..9d30c046 100644 --- a/resources/views/admin/extensions.blade.php +++ b/resources/views/admin/extensions.blade.php @@ -107,7 +107,8 @@ - @foreach($blueprint->extensions() as $extension) + @foreach($blueprint->extensionsConfigs() as $extension) + {{ $extension = $extension['info'] }} @include("blueprint.admin.entry", [ 'EXTENSION_ID' => $extension['identifier'], 'EXTENSION_NAME' => $extension['name'], diff --git a/routes/blueprint.php b/routes/blueprint.php index e516874b..20fdf891 100644 --- a/routes/blueprint.php +++ b/routes/blueprint.php @@ -26,7 +26,8 @@ Route::patch('/config', [Pterodactyl\BlueprintFramework\Controllers\ExtensionConfigurationController::class, 'update']); }); -foreach ($blueprint->extensions() as $extension) { +foreach ($blueprint->extensionsConfigs() as $extension) { + $extension = $extension['info']; $identifier = $extension['identifier']; $controllerName = $identifier . 'ExtensionController'; From 4393db0f29b9233d4b95c6fe55051e9691e39027 Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 11 Apr 2025 07:19:50 -0600 Subject: [PATCH 3/4] fix: telementry api --- app/Services/Telemetry/BlueprintTelemetryCollectionService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/Telemetry/BlueprintTelemetryCollectionService.php b/app/Services/Telemetry/BlueprintTelemetryCollectionService.php index 9a503908..141a0bb3 100644 --- a/app/Services/Telemetry/BlueprintTelemetryCollectionService.php +++ b/app/Services/Telemetry/BlueprintTelemetryCollectionService.php @@ -77,7 +77,7 @@ public function collect(): array 'blueprint' => [ 'version' => $this->placeholderService->version(), - 'extensions' => $this->blueprint->extensions(), + 'extensions' => $this->blueprint->extensionsConfigs()->toArray(), 'flags' => $flags, 'docker' => file_exists('/.dockerenv'), ], From f7ecd49c2ed225ae24350bb0f78b808467b1a1e4 Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 11 Apr 2025 07:47:48 -0600 Subject: [PATCH 4/4] fix: telemetry api x2 --- .../Telemetry/BlueprintTelemetryCollectionService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Services/Telemetry/BlueprintTelemetryCollectionService.php b/app/Services/Telemetry/BlueprintTelemetryCollectionService.php index 141a0bb3..e011ff3d 100644 --- a/app/Services/Telemetry/BlueprintTelemetryCollectionService.php +++ b/app/Services/Telemetry/BlueprintTelemetryCollectionService.php @@ -77,7 +77,9 @@ public function collect(): array 'blueprint' => [ 'version' => $this->placeholderService->version(), - 'extensions' => $this->blueprint->extensionsConfigs()->toArray(), + 'extensions' => array_map(function ($config) { + return $config['info'] ?? null; + }, $this->blueprint->extensionsConfigs()->toArray()), 'flags' => $flags, 'docker' => file_exists('/.dockerenv'), ],