Skip to content

Commit

Permalink
Merge pull request #83 from Bearsampp/bruno
Browse files Browse the repository at this point in the history
Add Bruno IDE tool support and update language files
  • Loading branch information
jwaisner authored Sep 13, 2024
2 parents b13a5f3 + 294ff29 commit f0b0c94
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 28 deletions.
1 change: 1 addition & 0 deletions core/classes/actions/class.action.quickPick.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class QuickPick
public $modules = [
'Adminer' => ['type' => 'application'],
'Apache' => ['type' => 'binary'],
'Bruno' => ['type' => 'tools'],
'Composer' => ['type' => 'tools'],
'ConsoleZ' => ['type' => 'tools'],
'Ghostscript' => ['type' => 'tools'],
Expand Down
2 changes: 2 additions & 0 deletions core/classes/class.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Lang
const PHPPGADMIN = 'phppgadmin';

// Tools
const BRUNO = 'bruno';
const COMPOSER = 'composer';
const CONSOLEZ = 'consolez';
const GHOSTSCRIPT = 'ghostscript';
Expand Down Expand Up @@ -508,6 +509,7 @@ public static function getKeys()
self::PHPPGADMIN,

// Tools
self::BRUNO,
self::COMPOSER,
self::CONSOLEZ,
self::GIT,
Expand Down
14 changes: 8 additions & 6 deletions core/classes/class.symlinks.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/*
* Copyright (c) 2021-2024 Bearsampp
* License: GNU General Public License version 3 or later; see LICENSE.txt
* Author: Bear
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
Expand Down Expand Up @@ -72,7 +73,8 @@ public static function deleteCurrentSymlinks()
'22' => Util::formatWindowsPath($toolsPath . '/xdc/current'),
'23' => Util::formatWindowsPath($toolsPath . '/yarn/current'),
'24' => Util::formatWindowsPath($binPath . '/xlight/current'),
'25' => Util::formatWindowsPath($binPath . '/mailpit/current')
'25' => Util::formatWindowsPath($binPath . '/mailpit/current'),
'26' => Util::formatWindowsPath($binPath . '/bruno/current')
];

if (!is_array($array) || empty($array)) {
Expand Down
116 changes: 116 additions & 0 deletions core/classes/tools/class.tool.bruno.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php
/*
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
* Class ToolBruno
*
* This class represents the Bruno tool module in the Bearsampp application.
* It extends the abstract Module class and provides specific functionalities
* for managing the Bruno IDE tool, including setting versions,
* and retrieving the executable path.
*/
class ToolBruno extends Module
{
/**
* Configuration key for the Bruno version in the root configuration.
*/
const ROOT_CFG_VERSION = 'brunoVersion';

/**
* Configuration key for the Bruno executable in the local configuration.
*/
const LOCAL_CFG_EXE = 'brunoExe';

/**
* Path to the Bruno executable.
*
* @var string
*/
private $exe;

/**
* Constructor for the ToolBruno class.
*
* Initializes the ToolBruno instance by logging the initialization and reloading
* the module configuration with the provided ID and type.
*
* @param string $id The ID of the module.
* @param string $type The type of the module.
*/
public function __construct($id, $type) {
Util::logInitClass($this);
$this->reload($id, $type);
}

/**
* Reloads the module configuration based on the provided ID and type.
*
* This method overrides the parent reload method to include additional
* configurations specific to the Bruno tool. It sets the name, version, and
* executable path, and logs errors if the module is not properly configured.
*
* @param string|null $id The ID of the module. If null, the current ID is used.
* @param string|null $type The type of the module. If null, the current type is used.
*/
public function reload($id = null, $type = null) {
global $bearsamppConfig, $bearsamppLang;
Util::logReloadClass($this);

$this->name = $bearsamppLang->getValue(Lang::BRUNO);
$this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
parent::reload($id, $type);

if ($this->bearsamppConfRaw !== false) {
$this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
}

if (!$this->enable) {
Util::logInfo($this->name . ' is not enabled!');
return;
}
if (!is_dir($this->currentPath)) {
Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
}
if (!is_dir($this->symlinkPath)) {
Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
return;
}
if (!is_file($this->bearsamppConf)) {
Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
}
if (!is_file($this->exe)) {
Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
}
}

/**
* Sets the version of the Bruno IDE tool.
*
* This method updates the version in the configuration and reloads the module
* to apply the new version.
*
* @param string $version The version to set.
*/
public function setVersion($version) {
global $bearsamppConfig;
$this->version = $version;
$bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
$this->reload();
}

/**
* Gets the path to the Bruno executable.
*
* @return string The path to the Bruno executable.
*/
public function getExe() {
return $this->exe;
}
}
30 changes: 25 additions & 5 deletions core/classes/tools/class.tools.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/*
* Copyright (c) 2021-2024 Bearsampp
* License: GNU General Public License version 3 or later; see LICENSE.txt
* Author: Bear
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
Expand All @@ -25,6 +26,11 @@ class Tools
*/
private $composer;

/**
* @var ToolBruno|null The Bruno tool instance.
*/
private $bruno;

/**
* @var ToolConsoleZ|null The ConsoleZ tool instance.
*/
Expand Down Expand Up @@ -96,6 +102,7 @@ public function update()
public function getAll()
{
return array(
$this->getBruno(),
$this->getComposer(),
$this->getConsoleZ(),
$this->getGhostscript(),
Expand All @@ -109,6 +116,19 @@ public function getAll()
);
}

/**
* Retrieves the Bruno tool instance.
*
* @return ToolBruno The Bruno tool instance.
*/
public function getBruno()
{
if ($this->bruno == null) {
$this->bruno = new ToolBruno('bruno', self::TYPE);
}
return $this->bruno;
}

/**
* Retrieves the Composer tool instance.
*
Expand Down
32 changes: 20 additions & 12 deletions core/classes/tpls/app/class.tpl.app.tools.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/*
* Copyright (c) 2021-2024 Bearsampp
* License: GNU General Public License version 3 or later; see LICENSE.txt
* Author: bear
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
Expand Down Expand Up @@ -58,6 +59,13 @@ public static function getMenuTools()
$resultItems .= $tplPython[TplApp::SECTION_CALL] . PHP_EOL;
$resultActions .= $tplPython[TplApp::SECTION_CONTENT] . PHP_EOL;

// Bruno postman IDE
$resultItems .= TplAestan::getItemExe(
$bearsamppLang->getValue(Lang::BRUNO),
$bearsamppTools->getBruno()->getExe(),
TplAestan::GLYPH_BRUNO
) . PHP_EOL;

// Composer
$resultItems .= TplAestan::getItemConsoleZ(
$bearsamppLang->getValue(Lang::COMPOSER),
Expand Down Expand Up @@ -128,6 +136,13 @@ public static function getMenuTools()
TplAestan::GLYPH_HOSTSEDITOR
) . PHP_EOL;

// Pwgen password manager
$resultItems .= TplAestan::getItemExe(
$bearsamppLang->getValue(Lang::PWGEN),
$bearsamppCore->getPwgenExe(),
TplAestan::GLYPH_PWGEN
) . PHP_EOL;

// Generate SSL Certificate
$tplGenSslCertificate = TplApp::getActionMulti(
self::ACTION_GEN_SSL_CERTIFICATE, null,
Expand All @@ -137,13 +152,6 @@ public static function getMenuTools()
$resultItems .= $tplGenSslCertificate[TplApp::SECTION_CALL] . PHP_EOL;
$resultActions .= $tplGenSslCertificate[TplApp::SECTION_CONTENT];

// Pwgen password manager
$resultItems .= TplAestan::getItemExe(
$bearsamppLang->getValue(Lang::PWGEN),
$bearsamppCore->getPwgenExe(),
TplAestan::GLYPH_PWGEN
) . PHP_EOL;

return $resultItems . PHP_EOL . $resultActions;
}

Expand Down
12 changes: 7 additions & 5 deletions core/classes/tpls/class.tpl.aestan.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/*
* Copyright (c) 2021-2024 Bearsampp
* License: GNU General Public License version 3 or later; see LICENSE.txt
* Author: Bear
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
Expand Down Expand Up @@ -97,6 +98,7 @@ class TplAestan
const GLYPH_PWGEN = 58;
const GLYPH_XLIGHT = 59;
const GLYPH_REBUILD_INI = 60;
const GLYPH_BRUNO = 61;

// Service actions
const SERVICE_START = 'startresume';
Expand Down
1 change: 1 addition & 0 deletions core/langs/english.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"

; Tools
bruno = "Bruno"
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
Expand Down
1 change: 1 addition & 0 deletions core/langs/french.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"

; Tools
bruno = "Bruno"
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
Expand Down
1 change: 1 addition & 0 deletions core/langs/german.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"

; Tools
bruno = "Bruno"
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
Expand Down
1 change: 1 addition & 0 deletions core/langs/hungarian.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"

; Tools
bruno = "Bruno"
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
Expand Down
1 change: 1 addition & 0 deletions core/langs/spanish.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"

; Herramientas
bruno = "Bruno"
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
Expand Down
1 change: 1 addition & 0 deletions core/langs/swedish.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"

; Tools
bruno = "Bruno"
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
Expand Down
Binary file added core/resources/homepage/img/bruno.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sprites.dat
Binary file not shown.

0 comments on commit f0b0c94

Please sign in to comment.