Renaming console commands

This commit is contained in:
Axel 2023-05-21 18:17:31 +02:00
parent 5969ff0de0
commit 52059e110d
Signed by: axel
GPG key ID: 73C0A5961B6BC740
5 changed files with 16 additions and 19 deletions

View file

@ -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
);
}

View file

@ -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');

View file

@ -13,7 +13,7 @@ class PurgeFiles extends Command
*
* @var string
*/
protected $signature = 'fs:purge-expired';
protected $signature = 'fs:bundle:purge';
/**
* The console command description.

View file

@ -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();
}
/**

View file

@ -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**.