Skip to content

Commit

Permalink
feat: swap laravel webpack with laravel vite (#62)
Browse files Browse the repository at this point in the history
* Switch to laravel vite

* update stubs lv9

* wip

* fix

* Fix tests

* Test build before tests

* Update laravel.yml

* Update laravel.yml
  • Loading branch information
Simoneu01 authored Oct 8, 2023
1 parent 3359b70 commit fdaa7a7
Show file tree
Hide file tree
Showing 45 changed files with 4,353 additions and 44,543 deletions.
20 changes: 13 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
Expand All @@ -46,24 +46,30 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

GAMESHARD_CLIENT_ID=
GAMESHARD_CLIENT_SECRET=
GAMESHARD_REDIRECT_URL="${APP_URL}/gameshard/callback"
GAMESHARD_REDIRECT_URL="${APP_URL}/oauth/gameshard/callback"
GAMESHARD_API_KEY=

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URL="${APP_URL}/github/callback"
GITHUB_REDIRECT_URL="${APP_URL}/oauth/github/callback"

DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_REDIRECT_URL="${APP_URL}/discord/callback"
DISCORD_REDIRECT_URL="${APP_URL}/oauth/discord/callback"

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL="${APP_URL}/google/callback"
GOOGLE_REDIRECT_URL="${APP_URL}/oauth/google/callback"
36 changes: 14 additions & 22 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
coverage: pcov

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
Expand All @@ -32,6 +32,18 @@ jobs:
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
check-latest: true

- name: Install NPM dependencies
run: npm install

- name: Compile assets
run: npm run build

- name: Create Database
run: |
mkdir -p database
Expand All @@ -51,30 +63,10 @@ jobs:
path: storage/logs

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: tests
verbose: true
fail_ci_if_error: true

build:
runs-on: ubuntu-latest
needs: laravel-tests

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true

- name: Install NPM dependencies
run: npm install

- name: Compile assets for production
run: npm run production
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
.idea
/.fleet
/.idea
/.vscode
5 changes: 1 addition & 4 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ php:
not-name:
- index.php

js:
finder:
not-name:
- webpack.mix.js
js: true
css: true
9 changes: 5 additions & 4 deletions app/Actions/Socialstream/CreateConnectedAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Actions\Socialstream;

use Illuminate\Contracts\Auth\Authenticatable;
use JoelButcher\Socialstream\ConnectedAccount;
use JoelButcher\Socialstream\Contracts\CreatesConnectedAccounts;
use JoelButcher\Socialstream\Socialstream;
use Laravel\Socialite\Contracts\User as ProviderUser;
Expand All @@ -12,11 +10,14 @@ class CreateConnectedAccount implements CreatesConnectedAccounts
{
/**
* Create a connected account for a given user.
*
* @param mixed $user
* @return \JoelButcher\Socialstream\ConnectedAccount
*/
public function create(Authenticatable $user, string $provider, ProviderUser $providerUser): ConnectedAccount
public function create($user, string $provider, ProviderUser $providerUser)
{
return Socialstream::connectedAccountModel()::forceCreate([
'user_id' => $user->getAuthIdentifier(),
'user_id' => $user->id,
'provider' => strtolower($provider),
'provider_id' => $providerUser->getId(),
'name' => $providerUser->getName(),
Expand Down
19 changes: 19 additions & 0 deletions app/Actions/Socialstream/GenerateRedirectForProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Actions\Socialstream;

use JoelButcher\Socialstream\Contracts\GeneratesProviderRedirect;
use Laravel\Socialite\Facades\Socialite;

class GenerateRedirectForProvider implements GeneratesProviderRedirect
{
/**
* Generates the redirect for a given provider.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function generate(string $provider)
{
return Socialite::driver($provider)->redirect();
}
}
4 changes: 3 additions & 1 deletion app/Actions/Socialstream/HandleInvalidState.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class HandleInvalidState implements HandlesInvalidState
{
/**
* Handle an invalid state exception from a Socialite provider.
*
* @return mixed
*/
public function handle(InvalidStateException $exception, callable $callback = null): mixed
public function handle(InvalidStateException $exception, callable $callback = null)
{
if ($callback) {
return $callback($exception);
Expand Down
6 changes: 2 additions & 4 deletions app/Enums/SocialEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public function getIcon(): string
SocialEnum::LINKEDIN => 'fab-linkedin',
SocialEnum::INSTAGRAM => 'fab-instagram',
SocialEnum::FACEBOOK => 'fab-facebook',
SocialEnum::TWITCH => 'fab-twitch',
default => 'fas-hashtag'
SocialEnum::TWITCH => 'fab-twitch'
};
}

Expand All @@ -29,8 +28,7 @@ public function getClasses(): string
SocialEnum::LINKEDIN => 'hover:text-[#0e76a8]',
SocialEnum::INSTAGRAM => 'hover:text-orange-500',
SocialEnum::FACEBOOK => 'hover:text-[#1778F2]',
SocialEnum::TWITCH => 'hover:text-[#9147ff]',
default => 'hover:text-gray-500'
SocialEnum::TWITCH => 'hover:text-[#9147ff]'
};
}

Expand Down
13 changes: 11 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Kernel extends HttpKernel
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
Expand Down
6 changes: 1 addition & 5 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string|null
*/
/** {@inheritdoc} */
protected $proxies;

/**
Expand Down
22 changes: 22 additions & 0 deletions app/Http/Middleware/ValidateSignature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Routing\Middleware\ValidateSignature as Middleware;

class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}
20 changes: 20 additions & 0 deletions app/Policies/ConnectedAccountPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ class ConnectedAccountPolicy
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*
* @return mixed
*/
public function viewAny(User $user)
{
return true;
}

/**
* Determine whether the user can view the model.
*
Expand All @@ -20,6 +30,16 @@ public function view(User $user, ConnectedAccount $connectedAccount)
return $user->ownsConnectedAccount($connectedAccount);
}

/**
* Determine whether the user can create models.
*
* @return mixed
*/
public function create(User $user)
{
return true;
}

/**
* Determine whether the user can update the model.
*
Expand Down
6 changes: 2 additions & 4 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
Expand All @@ -21,10 +21,8 @@ class AuthServiceProvider extends ServiceProvider

/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->registerPolicies();

Expand Down
6 changes: 2 additions & 4 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
Expand All @@ -37,10 +37,8 @@ public function boot()

/**
* Determine if events and listeners should be automatically discovered.
*
* @return bool
*/
public function shouldDiscoverEvents()
public function shouldDiscoverEvents(): bool
{
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class RouteServiceProvider extends ServiceProvider
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/dashboard';

/**
* Define your route model bindings, pattern filters, etc.
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
Expand All @@ -29,8 +29,8 @@ public function boot()
$this->configureRateLimiting();

$this->routes(function () {
Route::prefix('api')
->middleware('api')
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));

Route::middleware('web')
Expand Down
Loading

0 comments on commit fdaa7a7

Please sign in to comment.