-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-> Add lint -> More work!
- Loading branch information
Showing
94 changed files
with
4,045 additions
and
1,503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- "develop" | ||
- "1.0-develop" | ||
pull_request: | ||
branches: | ||
- "develop" | ||
- "1.0-develop" | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: "8.3" | ||
extensions: bcmath, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist | ||
|
||
- name: PHP CS Fixer (APP) | ||
run: vendor/bin/php-cs-fixer fix app --dry-run | ||
|
||
- name: PHP CS Fixer (Tests) | ||
run: vendor/bin/php-cs-fixer fix tests --dry-run | ||
- name: PHP CS Fixer (Routes) | ||
run: vendor/bin/php-cs-fixer fix routes --dry-run | ||
- name: PHP CS Fixer (Lang) | ||
run: vendor/bin/php-cs-fixer fix lang --dry-run | ||
- name: PHP CS Fixer (Cron) | ||
run: vendor/bin/php-cs-fixer fix lang --dry-run | ||
- name: PHP CS Fixer (API) | ||
run: vendor/bin/php-cs-fixer fix api --dry-run | ||
- name: PHP CS Fixer (Addons) | ||
run: vendor/bin/php-cs-fixer fix addons --dry-run | ||
- name: PHP CS Fixer (Commands) | ||
run: vendor/bin/php-cs-fixer fix commands --dry-run | ||
- name: PHP CS Fixer (Install) | ||
run: vendor/bin/php-cs-fixer fix install --dry-run | ||
- name: PHP CS Fixer (Public) | ||
run: vendor/bin/php-cs-fixer fix public --dry-run | ||
- name: PHP CS Fixer (Migrate) | ||
run: vendor/bin/php-cs-fixer fix migrate --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ composer.phar | |
/test.json | ||
/caches/*/ | ||
caches/last_settings_migrate_run | ||
.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,8 @@ | |
|
||
class Example | ||
{ | ||
|
||
public function Main(array $args = []) | ||
{ | ||
|
||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace MythicalSystemsFramework\Cli\Commands; | ||
|
||
class Colors extends Command | ||
{ | ||
public static string $description = 'A command to display the supported colors!'; | ||
|
||
public static function execute(bool $isFrameworkCommand = false): void | ||
{ | ||
$colors = "Colors: &0Black&r, &1Dark Blue&r, &2Dark Green&r, &3Dark Aqua&r, &4Dark Red&r, &5Dark Purple&r, &6Gold&r, &7Gray&r, &8Dark Gray&r, &9Blue&r, &aGreen&r, &bAqua&r, &cRed&r, &dLight Purple&r, &eYellow&r, &fWhite&r, &rReset&r, &lBold&r, &nUnderline&r, &mStrikethrough&r"; | ||
echo self::translateColorsCode($colors); | ||
echo PHP_EOL; | ||
echo str_replace('&r', '', $colors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace MythicalSystemsFramework\Cli\Commands; | ||
|
||
use MythicalSystemsFramework\Cli\Kernel; | ||
|
||
class Command extends Kernel | ||
{ | ||
public static string $description = 'A example command :)'; | ||
|
||
public static function execute(bool $isFrameworkCommand = false): void | ||
{ | ||
/** | ||
* This method should be overridden in the child class. | ||
*/ | ||
echo self::translateColorsCode("Command executed &asuccessfully&r!"); | ||
|
||
} | ||
/** | ||
* Logs a success message to the console. | ||
* | ||
* @requires \MythicalSystemsFramework\Cli\Commands\Colors | ||
* | ||
* @param string $message The message to log. | ||
* | ||
* @return void | ||
*/ | ||
public static function log_success(string $message): void | ||
{ | ||
echo self::translateColorsCode("&a$message&r&o"); | ||
} | ||
/** | ||
* Logs a error message to the console. | ||
* | ||
* @requires \MythicalSystemsFramework\Cli\Commands\Colors | ||
* | ||
* @param string $message The message to log. | ||
* | ||
* @return void | ||
*/ | ||
public static function log_error(string $message): void | ||
{ | ||
echo self::translateColorsCode("&c$message&r&o"); | ||
} | ||
/** | ||
* Logs a warning message to the console. | ||
* | ||
* @requires \MythicalSystemsFramework\Cli\Commands\Colors | ||
* | ||
* @param string $message The message to log. | ||
* | ||
* @return void | ||
*/ | ||
public static function log_warning(string $message): void | ||
{ | ||
echo self::translateColorsCode("&e$message&r&o"); | ||
} | ||
/** | ||
* Logs a info message to the console. | ||
* | ||
* @requires \MythicalSystemsFramework\Cli\Commands\Colors | ||
* | ||
* @param string $message The message to log. | ||
* | ||
* @return void | ||
*/ | ||
public static function log_info(string $message): void | ||
{ | ||
echo self::translateColorsCode("&7$message&r&o"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace MythicalSystemsFramework\Cli\Commands; | ||
|
||
use Exception; | ||
use MythicalSystemsFramework\Database\MySQL; | ||
use MythicalSystemsFramework\Managers\ConfigManager as cfg; | ||
use MythicalSystemsFramework\Managers\Settings; | ||
|
||
class Configure extends Command | ||
{ | ||
public static string $description = 'A command that can help if you want to configure the app!'; | ||
public static function execute(bool $isFrameworkCommand = false): void | ||
{ | ||
echo self::log_info(""); | ||
echo self::log_info("&c1.&7 Configure the database"); | ||
echo self::log_info("&c2.&7 Configure the app"); | ||
echo self::log_info("&c3.&7 Exit"); | ||
echo self::log_info(""); | ||
|
||
$option = readline("Select an option: "); | ||
|
||
switch ($option) { | ||
case '1': | ||
self::dbconfigure(); | ||
break; | ||
case '2': | ||
self::configure(); | ||
break; | ||
case '3': | ||
self::exit(); | ||
break; | ||
default: | ||
echo "Invalid option selected."; | ||
break; | ||
} | ||
} | ||
|
||
public static function dbconfigure(): void | ||
{ | ||
if (cfg::get("database", "password") !== null) { | ||
echo self::translateColorsCode("&fDatabase configuration already exists. &oWould you like to overwrite it? &8[&aY&8/&cN&8]&f: "); | ||
$overwrite = readline(); | ||
if (strtolower($overwrite) !== "y") { | ||
return; | ||
} | ||
} | ||
$defaultHost = "127.0.0.1"; | ||
$defaultPort = "3306"; | ||
$db = new MySQL(); | ||
echo self::translateColorsCode("&fEnter the host of the database &8[&e$defaultHost&8]&f: "); | ||
$host = readline() ?: $defaultHost; | ||
echo self::translateColorsCode("&fEnter the port of the database &8[&e$defaultPort&8]&f: "); | ||
$port = readline() ?: $defaultPort; | ||
echo self::translateColorsCode("&fEnter the username: "); | ||
$username = readline(); | ||
echo self::translateColorsCode("&fEnter the password: "); | ||
$password = readline(); | ||
echo self::translateColorsCode("&fEnter the database name: "); | ||
$database = readline(); | ||
// Perform validation | ||
if (empty($username) || empty($password) || empty($database)) { | ||
echo self::translateColorsCode("&cPlease provide all the required information.&o"); | ||
return; | ||
} | ||
|
||
// Hide the password | ||
$hiddenPassword = str_repeat('*', strlen($password)); | ||
|
||
// Use the provided information | ||
echo self::NewLine(); | ||
echo self::translateColorsCode("&fHost: &e$host&o"); | ||
echo self::translateColorsCode("&fPort: &e$port&o"); | ||
echo self::translateColorsCode("&fUsername: &e$username&o"); | ||
echo self::translateColorsCode("&fPassword: &e$hiddenPassword&o"); | ||
echo self::translateColorsCode("&fDatabase: &e$database&o"); | ||
|
||
if ($db->tryConnection($host, $port, $username, $password, $database) == true) { | ||
echo self::NewLine(); | ||
echo self::translateColorsCode("&fConnection to the database was &asuccessful!&o"); | ||
echo self::NewLine(); | ||
echo self::translateColorsCode("&fSaving the configuration...&o"); | ||
cfg::set("database", "host", $host); | ||
cfg::set("database", "port", $port); | ||
cfg::set("database", "username", $username); | ||
cfg::set("database", "password", $password); | ||
cfg::set("database", "name", $database); | ||
echo self::translateColorsCode("&fConfiguration saved &asuccessfully!&o"); | ||
} else { | ||
echo self::translateColorsCode("&7Failed to connect to the database. &o&fPlease check the provided information."); | ||
} | ||
|
||
} | ||
|
||
public static function configure(): void | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace MythicalSystemsFramework\Cli\Commands; | ||
|
||
use MythicalSystemsFramework\Managers\ConfigManager as cfg; | ||
|
||
class Down extends Command | ||
{ | ||
public static string $description = 'Mark the application as down.'; | ||
|
||
public static function execute(bool $isFrameworkCommand = false): void | ||
{ | ||
echo self::log_info("Marking the application as down..."); | ||
if (cfg::get('app', 'maintenance') == "true" && cfg::get('app', 'maintenance') != "false") { | ||
echo self::translateColorsCode("&aApplication &ris already in maintenance mode!"); | ||
return; | ||
} | ||
cfg::set('app', 'maintenance', "true"); | ||
echo self::log_success("Application is now down!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace MythicalSystemsFramework\Cli\Commands; | ||
|
||
class Help extends Command | ||
{ | ||
public static string $description = 'The help command to get info about other commands!'; | ||
|
||
public static function execute(bool $isFrameworkCommand = false): void | ||
{ | ||
echo self::log_info(""); | ||
echo self::log_info("-----------------------"); | ||
echo self::log_info("| Available commands: |"); | ||
echo self::log_info("-----------------------"); | ||
echo self::log_info(""); | ||
|
||
$commands = scandir(__DIR__); | ||
foreach ($commands as $command) { | ||
if ($command === '.' || $command === '..' || $command === 'Command.php') { | ||
continue; | ||
} | ||
|
||
$command = str_replace('.php', '', $command); | ||
$commandClass = "MythicalSystemsFramework\\Cli\\Commands\\$command"; | ||
$reflectionClass = new \ReflectionClass($commandClass); | ||
|
||
if (!$reflectionClass->hasProperty('description')) { | ||
continue; | ||
} | ||
|
||
echo self::log_info("{$command} > {$reflectionClass->getProperty('description')->getValue()}"); | ||
} | ||
echo self::log_info(""); | ||
} | ||
} |
Oops, something went wrong.