Skip to content

Commit

Permalink
feat: work in progress query command and add bp:telemetry command
Browse files Browse the repository at this point in the history
  • Loading branch information
prplwtf committed Dec 27, 2024
1 parent b4303bc commit fb290ff
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 31 deletions.
31 changes: 31 additions & 0 deletions app/Console/Commands/BlueprintFramework/TelemetryCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Pterodactyl\Console\Commands\BlueprintFramework;

use Illuminate\Console\Command;
use Symfony\Component\VarDumper\VarDumper;
use Pterodactyl\Services\Telemetry\BlueprintTelemetryCollectionService;


class TelemetryCommand extends Command
{
protected $description = 'Displays all the data that would be sent to the Blueprint Telemetry Service if telemetry collection is enabled';
protected $signature = 'bp:telemetry';

/**
* TelemetryCommand constructor.
*/
public function __construct(
private BlueprintTelemetryCollectionService $blueprintTelemetryCollectionService,
) {
parent::__construct();
}

/**
* Handle execution of command.
*/
public function handle()
{
VarDumper::dump($this->blueprintTelemetryCollectionService->collect());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class VersionCacheCommand extends Command
protected $signature = 'bp:version:cache';

/**
* VersionFetchCommand constructor.
* VersionCacheCommand constructor.
*/
public function __construct(
private BlueprintPlaceholderService $PlaceholderService,
Expand Down
5 changes: 3 additions & 2 deletions blueprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
cmd="${COMP_WORDS[1]}"

case "${cmd}" in
-install|-add|-i)
-install|-add|-i|-query|-q)
opts="$(
find "$BLUEPRINT__SOURCEFOLDER"/*.blueprint 2> /dev/null |
sed -e "s|^$BLUEPRINT__SOURCEFOLDER/||g" -e "s|.blueprint$||g"
Expand All @@ -52,7 +52,7 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
-export) opts="expose" ;;
-upgrade) opts="remote" ;;

*) opts="-install -add -remove -init -build -export -wipe -version -help -info -debug -upgrade -rerun-install" ;;
*) opts="-install -add -remove -query -init -build -export -wipe -version -help -info -debug -upgrade -rerun-install" ;;
esac

if [[ ${cur} == * ]]; then
Expand Down Expand Up @@ -358,6 +358,7 @@ cmd="${2}"
case "$cmd" in
-add|-install|-i) source ./scripts/commands/extensions/install.sh ;;
-remove|-r) source ./scripts/commands/extensions/remove.sh ;;
-query|-q) source ./scripts/commands/extensions/query.sh ;;
-init|-I) source ./scripts/commands/developer/init.sh ;;
-build|-b) source ./scripts/commands/developer/build.sh ;;
-wipe|-w) source ./scripts/commands/developer/wipe.sh ;;
Expand Down
28 changes: 0 additions & 28 deletions blueprint/design/schema.txt

This file was deleted.

59 changes: 59 additions & 0 deletions scripts/commands/extensions/query.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

Command() {
if [[ $1 == "" ]]; then PRINT FATAL "Expected 1 argument but got 0.";exit 2;fi

PRINT INFO "Searching and validating framework dependencies.."
# Check if required programs and libraries are installed.
depend

PRINT INFO "Extracting extension.."
dev=false
n="$1"

if [[ $n == *".blueprint" ]]; then n="${n::-10}";fi
FILE="${n}.blueprint"

if [[ ! -f "$FILE" ]]; then PRINT FATAL "$FILE could not be found or detected.";return 2;fi

ZIP="${n}.zip"
cp "$FILE" ".blueprint/tmp/$ZIP"
cd ".blueprint/tmp" || cdhalt
unzip -o -qq "$ZIP"
rm "$ZIP"
if [[ ! -f "$n/*" ]]; then
cd ".." || cdhalt
rm -R "tmp"
mkdir -p "tmp"
cd "tmp" || cdhalt

mkdir -p "./$n"
cp "../../$FILE" "./$n/$ZIP"
cd "$n" || cdhalt
unzip -o -qq "$ZIP"
rm "$ZIP"
cd ".." || cdhalt
fi

# Return to the Pterodactyl installation folder.
cd "$FOLDER" || cdhalt

# Get all strings from the conf.yml file and make them accessible as variables.
if [[ ! -f ".blueprint/tmp/$n/conf.yml" ]]; then
# Quit if the extension doesn't have a conf.yml file.
rm -R ".blueprint/tmp/$n"
PRINT FATAL "Extension configuration file not found or detected."
return 1
fi

eval "$(parse_yaml .blueprint/tmp/"${n}"/conf.yml conf_)"

echo $conf__

echo -e \
"\x1b[37;1mnebula.blueprint\x1b[0m"

rm -R ".blueprint/tmp/$n"

exit 0
}
1 change: 1 addition & 0 deletions scripts/commands/misc/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Command() {
\x1b[34;1mExtensions\x1b[0m\x1b[34m
-install [name] -add -i install/update a blueprint extension
-remove [name] -r remove a blueprint extension
-query [name] -q information about a specific blueprint extension
\x1b[0m
${help_dev_primary}Developer${help_dev_status}\x1b[0m${help_dev_secondary}
Expand Down

0 comments on commit fb290ff

Please sign in to comment.