Skip to content

Commit

Permalink
Version 2.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JSn1nj4 committed Jun 25, 2024
2 parents 8530fed + 96960cd commit bb7ad18
Show file tree
Hide file tree
Showing 51 changed files with 309 additions and 2,549 deletions.
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DB_CONNECTION=sqlite
DB_DATABASE=:memory:

BROADCAST_DRIVER=log
CACHE_DRIVER=file
CACHE_DRIVER=database
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
ssh deploy-host "cd \"$DEPLOY_HOST_PROJECT_ROOT\" \
&& git checkout \"$DEPLOY_BRANCH\" \
&& git reset --hard \
&& git clean -f -d \
&& git pull \
&& composer install --no-dev \
&& yarn && yarn prod"
Expand Down
82 changes: 0 additions & 82 deletions .lando.base.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .run/start-mailpit.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="start-mailpit" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="test $(command -v mailpit) &amp;&amp; mailpit" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/usr/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>
14 changes: 0 additions & 14 deletions .styleci.yml

This file was deleted.

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## Version 2.9.2

### Changes

- Update `session:flush` command
- Fix working with sessions file storage (if used)
- Forcefully log users out if using database driver
- Update profile pic on homepage

### Development

- No more Lando stuff
- Add Mailpit startup command
- Fix a potential deploy edge case caused by untracked files not being removed first

## Version 2.9.1

### Fix
Expand All @@ -20,6 +35,7 @@
### Development

- Purge old VS Code configs
- Start a bunch of missing tests

[is_39]: https://github.com/JSn1nj4/ElliotDerhay.com/issues/39

Expand Down
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

4 changes: 2 additions & 2 deletions app/Actions/MoveImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function __invoke(FileLocation $from, FileLocation $to): OperationResult
->readStream($from->path));

return $succeeded ?
$this->success("File on disk '{$from->disk}' at path '{$from->path}' moved to disk '{$to->disk}' at path '{$to->path}'.") :
$this->failure("Failed to move file on disk '{$from->disk}' at path disk '{$to->disk}' at path '{$to->path}'.");
$this->success("File on disk '{$from->disk}' at path '{$from->path}' moved to disk '{$to->disk}' at path '{$to->path}'.") :
$this->failure("Failed to move file on disk '{$from->disk}' at path '{$from->path}' disk '{$to->disk}' at path '{$to->path}'.");
}

public static function execute(
Expand Down
82 changes: 55 additions & 27 deletions app/Console/Commands/FlushSessionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,77 @@

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;

/**
* Largely based on this SO answer: https://stackoverflow.com/a/58881919/3470278
*/
class FlushSessionsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'session:flush';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Flush all login sessions.';

/**
* Execute the console command.
*/
public function handle(): int
{
return $this->{match (config('session.driver')) {
default => 'flushSessionsFolder',
}}();
}
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'session:flush';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Flush all login sessions.';

/**
* Execute the console command.
*/
public function handle(): int
{
$return = match (config('session.driver')) {
'file' => $this->flushSessionsFolder(),
default => $this->flushSessionsTable(),
};

$this->info('Sessions cleared!');

return $return;
}

private function flushSessionsFolder(): int
{
$this->info('Clearing session storage.');

$ignore = ['.gitignore', '.', '..'];

collect(Storage::disk('sessions')->allFiles())
->reject(fn ($item) => in_array($item, $ignore))
->each(fn ($item) => Storage::disk('sessions')->delete($item));
$disk = Storage::build([
'driver' => 'local',
'root' => storage_path('framework/sessions'),
]);

$this->info('Sessions cleared!');
collect($disk->allFiles())
->reject(static fn ($item) => in_array($item, $ignore))
->each(static fn ($item) => $disk->delete($item));

return self::SUCCESS;
}

private function flushSessionsTable(): int
{
$this->info("Clearing sessions table.");

$ids = DB::table(config('session.table'))
->select('user_id')
->distinct()
->whereNotNull('user_id')
->get()
->map(static fn ($item) => $item->user_id);

User::whereIn('id', $ids)->update(['remember_token' => null]);

DB::table(config('session.table'))->truncate();

return self::SUCCESS;
}
Expand Down
12 changes: 5 additions & 7 deletions app/Services/ImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace App\Services;

use App\Traits\MakesSelf;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;

class ImageService
{
Expand All @@ -19,11 +17,11 @@ public static function asset(string $filename): string

private static function ensureCached(string $path, string $disk): void
{
if (!Storage::disk('public-cache')->exists($path)) {
Storage::disk('public-cache')
->writeStream($path, Storage::disk($disk)
->readStream($path));
}
if (Storage::disk('public-cache')->exists($path)) return;

Storage::disk('public-cache')
->writeStream($path, Storage::disk($disk)
->readStream($path));
}

public function url(string $path, string $disk): string
Expand Down
26 changes: 12 additions & 14 deletions app/View/Components/Post/Latest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@

class Latest extends Component
{
public Post $post;
public Post|null $post;

/**
* Create a new component instance.
*/
public function __construct()
{
/**
* Create a new component instance.
*/
public function __construct() {
$this->post = Post::latest()->first();
}
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View
{
return view('components.post.latest');
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View {
return view('components.post.latest');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-faker": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpunit/phpunit": "^10.5",
"pestphp/pest-plugin-livewire": "^2.1",
"spatie/laravel-ignition": "^2.4"
},
"autoload": {
Expand Down
Loading

0 comments on commit bb7ad18

Please sign in to comment.