From 52059e110de20a5dc6e4e423a8326d32666539e9 Mon Sep 17 00:00:00 2001 From: Axel Date: Sun, 21 May 2023 18:17:31 +0200 Subject: [PATCH] Renaming console commands --- app/Console/Commands/CheckRelease.php | 8 ++------ app/Console/Commands/CreateUser.php | 19 ++++++++++--------- app/Console/Commands/PurgeFiles.php | 2 +- app/Console/Kernel.php | 2 +- readme.md | 4 ++-- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/app/Console/Commands/CheckRelease.php b/app/Console/Commands/CheckRelease.php index 390201f..00f64af 100644 --- a/app/Console/Commands/CheckRelease.php +++ b/app/Console/Commands/CheckRelease.php @@ -12,7 +12,7 @@ class CheckRelease extends Command * * @var string */ - protected $signature = 'fs:check-release'; + protected $signature = 'fs:app:releases'; /** * The console command description. @@ -34,10 +34,6 @@ class CheckRelease extends Command } else { foreach ($xml->entry as $e) { - // Title must be a version - if (! preg_match('~^[0-9]+\.[0-9]+~', $e->title)) { - continue; - } // Looking for the release link foreach ($e->link->attributes() as $k => $a) { @@ -57,7 +53,7 @@ class CheckRelease extends Command // Displaying the releases if (count($releases) > 0) { $this->table([ - 'Version', 'Updated', 'Link' + 'Version', 'Updated', 'Link' ], $releases ); } diff --git a/app/Console/Commands/CreateUser.php b/app/Console/Commands/CreateUser.php index 8c1c0c7..a96ca15 100644 --- a/app/Console/Commands/CreateUser.php +++ b/app/Console/Commands/CreateUser.php @@ -14,7 +14,7 @@ class CreateUser extends Command * * @var string */ - protected $signature = 'fs:create-user {login?}'; + protected $signature = 'fs:user:create {login?}'; /** * The console command description. @@ -28,16 +28,16 @@ class CreateUser extends Command */ public function handle() { - $login = $this->argument('login'); + $login = strtolower($this->argument('login')); login: // If user was not provided, asking for it if (empty($login)) { - $login = $this->ask('Enter the user\'s login'); + $login = strtolower($this->ask('Enter the user\'s login')); } - if (! preg_match('~^[a-z0-9]{1,40}$~', $login)) { - $this->error('Invalid login format. Must only contains letters and numbers, between 1 and 40 chars'); + if (! preg_match('~^[a-z0-9]{4,40}$~', $login)) { + $this->error('Invalid login format. Must only contains letters and numbers, between 4 and 40 chars'); unset($login); goto login; } @@ -53,16 +53,17 @@ class CreateUser extends Command // Asking for user's password $password = $this->secret('Enter the user\'s password'); - if (strlen($password) < 5) { - $this->error('Invalid password format. Must only contains 5 chars minimum'); + if (! preg_match('~^.{4,100}$i~', $password)) { + $this->error('Invalid password format. Must contains between 5 and 100 chars'); unset($password); goto password; } try { Storage::disk('users')->put($login.'.json', json_encode([ - 'login' => $login, - 'password' => Hash::make($password) + 'username' => $login, + 'password' => Hash::make($password), + 'bundles' => [] ])); $this->info('User has been created'); diff --git a/app/Console/Commands/PurgeFiles.php b/app/Console/Commands/PurgeFiles.php index 0140cb7..e0c434e 100644 --- a/app/Console/Commands/PurgeFiles.php +++ b/app/Console/Commands/PurgeFiles.php @@ -13,7 +13,7 @@ class PurgeFiles extends Command * * @var string */ - protected $signature = 'fs:purge-expired'; + protected $signature = 'fs:bundle:purge'; /** * The console command description. diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 5dc2cba..cd7dc1b 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule): void { // $schedule->command('inspire')->hourly(); - $schedule->command('fs:purge-expired')->hourly(); + $schedule->command('fs:bundle:purge')->hourly(); } /** diff --git a/readme.md b/readme.md index aac474d..87dd22c 100644 --- a/readme.md +++ b/readme.md @@ -80,9 +80,9 @@ The application also uses: - make sure that the PHP process has write permission on the `./storage` folder - generate the Laravel KEY: `php artisan key:generate` - run `cp .env.example .env` and edit `.env` to fit your needs -- (optional) you may create your first user `php artisan fs:create-user` +- (optional) you may create your first user `php artisan fs:user:create` - start the Laravel scheduler (it will delete expired bundles of the storage). For example `* * * * * /usr/bin/php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1` -- (optional) to purge bundles manually, run `php artisan fs:purge-expired` +- (optional) to purge bundles manually, run `php artisan fs:bundle:purge` Use your browser to navigate to your domain name (example: files.yourdomain.com) and **that's it**.