Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/laravel-enso/enso into ma…
Browse files Browse the repository at this point in the history
…ster

� Conflicts:
�	client/package.json
�	composer.json
�	composer.lock
�	database/factories/PersonFactory.php
�	database/seeders/CompanySeeder.php
�	database/seeders/CustomPermissionSeeder.php
�	database/seeds/RoleSeeder.php
�	database/seeds/UserSeeder.php
�	phpunit.xml
�	routes/api.php
  • Loading branch information
curtisdelicata committed Oct 16, 2020
2 parents 1c224fe + 9c15cb4 commit 075d15e
Show file tree
Hide file tree
Showing 68 changed files with 1,018 additions and 1,833 deletions.
3 changes: 2 additions & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

SENTRY_DSN=
SENTRY_LARAVEL_DSN=

TELESCOPE_ENABLED=0
SCOUT_DRIVER=null

ENSO_API_TOKEN=

Expand Down
84 changes: 84 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,89 @@
# Laravel Enso's Changelog

## 4.3.0

This release aims to upgrade the Enso ecosystem to [Laravel 8](https://laravel.com/docs/8.x/releases#laravel-8).

### Front-end

#### select
- the api request payload was cleaned up and null values are no longer sent to the back-end

### Back-end

Where necessary, packages have been updated to add Laravel 8 compatibility. Changes affect:
- factories
- seeders
- routes (now using imported controller classes instead of strings & namespaces)
- tests
- upgrades (older upgrades were deleted)
- dependencies versions

Where possible, we've kept packages backwards compatible.

#### logs
- fixes multiple log file types edge case bug

#### products
- removed default supplier limitation, where previously the default supplier had to have the lowest aquisition price

#### forms
- added support for the `searchMode` meta attribute, which can be used for select fields

### Upgrade steps

First and foremost, be sure the to read the official [Laravel 8 upgrade guide](https://laravel.com/docs/8.x/upgrade) to understand all implications.

Since we liked the previous flow of publishing factories and customizing them, we've created a `FactoryResolver` class that is used to emulate the old behavior. Basically, when using a factory to create a model, we first search in the local project factories folder and try to find a suitable factory class, otherwise we search for a factory in the factories folder in the laravel-enso package which contains the respective model.

The limitation for the factory naming convention is that if you have two models with the same name, with different namespaces, you'll need to customize the models' `newFactory()` method and implement your own strategy.

Also, note that starting with this release we're no longer doing a yarn legacy build (only modern) so please take a look at `package.json` & `babel.config.js` and update if necessary.

To upgrade:
- within `composer.json`
- update the versions for the following `require` packages
```
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel-enso/core": "^6.0",
"laravel/horizon": "^5.0",
"laravel/telescope": "^4.0",
"laravel/ui": "^3.0",
```
- update the versions for the following `require-dev` packages
```
"facade/ignition": "^2.3.6",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3"
```
- add the following namespaces to the `autoload/psr-4` section:
```
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
```
- remove the `classmap` block and its contents from the `autoload` section
- **update where necessary** by following this [merge request](https://github.com/laravel-enso/enso/pull/338) for a list of other updated files (local factories and seeders cleanup, config files and more).
- run `composer update`
- run `yarn`, `yarn upgrade && yarn` to ensure you have the latest package versions and patches are applied. If necessary, update your patch files
- `php artisan migrate`
- `composer dump-autoload`
- `php artisan enso:upgrade`
- update the Enso version to `4.3.0` in `config/enso/config.php`
Remember:
- you can delete any non customized local seeders and import them from their package
- update factories & seeders to
- use namespaces
- convert to classes
- rename the 'seeds' folder to 'seeders'
- update models with factories and add the new trait `HasFactory`
- update tests to
- use the new factories
- refactor around the deprecated json methods
- update routes by importing controllers as per the new syntax
- after updating your routes by importing the controller classes, you need to remove the `protected $namespace = 'App\Http\Controllers';` line in `RouteServiceProvider`
## 4.2.0
This release includes many improvements, bug fixes and a few new features.
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class Kernel extends HttpKernel
{
protected $middleware = [
\LaravelEnso\Core\Http\Middleware\AuthorizationCookie::class,
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
Expand All @@ -32,6 +33,7 @@ class Kernel extends HttpKernel
'api' => [
\LaravelEnso\Core\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
'throttle:api',
],
];

Expand Down
12 changes: 0 additions & 12 deletions app/Http/Middleware/CheckForMaintenanceMode.php

This file was deleted.

17 changes: 17 additions & 0 deletions app/Http/Middleware/PreventRequestsDuringMaintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;

class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
10 changes: 7 additions & 3 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

class RedirectIfAuthenticated
{
public function handle($request, Closure $next, $guard = null)
public function handle($request, Closure $next, ...$guards)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
$guards = empty($guards) ? [null] : $guards;

foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}

return $next($request);
Expand Down
20 changes: 20 additions & 0 deletions app/Http/Middleware/TrustHosts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustHosts as Middleware;

class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}
36 changes: 34 additions & 2 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,35 @@

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
public const HOME = '/';

protected $namespace = 'App\Http\Controllers';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';

public function map()
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();

$this->mapApiRoutes();

$this->mapWebRoutes();
Expand All @@ -32,4 +50,18 @@ protected function mapApiRoutes()
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}

/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return App::runningUnitTests()
? Limit::none()
: Limit::perMinute(1000);
});
}
}
8 changes: 7 additions & 1 deletion client/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
[
'@vue/app',
{
targets: { esmodules: true },
polyfills: [],
},
],
],
};
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@
"license": "ISC",
"repository": {
"type": "git",
"url": "http://github.com/genealogia/genealogy"
"url": "http://github.com/genealogiawebsite/genealogy"
}
}
14 changes: 7 additions & 7 deletions client/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const CopyPlugin = require('copy-webpack-plugin');
const SentryWebpackPlugin = require('@sentry/webpack-plugin');

const inProduction = () => process.env.NODE_ENV === 'production';
const usesSentry = () => process.env.SENTRY_AUTH_TOKEN
const inProduction = process.env.NODE_ENV === 'production';
const usesSentry = process.env.SENTRY_AUTH_TOKEN
&& process.env.SENTRY_PROJECT && process.env.SENTRY_ORG;

if (inProduction() && !usesSentry()) {
if (inProduction && !usesSentry) {
console.warn('For better error handing please configure sentry');
}

Expand All @@ -14,10 +14,10 @@ module.exports = {
main: {
entry: 'src/js/enso.js',
minify: true,
filename: inProduction()
filename: inProduction
? '../resources/views/index.blade.php'
: './index.html',
template: inProduction()
template: inProduction
? '../vendor/laravel-enso/core/stubs/production-index.blade.stub'
: '../vendor/laravel-enso/core/stubs/development-index.stub',
},
Expand All @@ -34,7 +34,7 @@ module.exports = {
},
outputDir: '../public/',
configureWebpack: {
devtool: inProduction() ? 'hidden-source-map' : 'source-map',
devtool: inProduction ? 'hidden-source-map' : 'source-map',
resolve: {
alias: {
'@core': `${__dirname}/node_modules/@enso-ui/ui/src`,
Expand All @@ -49,7 +49,7 @@ module.exports = {
},
},
plugins: [
inProduction() && usesSentry() && new SentryWebpackPlugin({
inProduction && usesSentry && new SentryWebpackPlugin({
include: '../public',
ignoreFile: '.sentrycliignore',
release: process.env.SENTRY_RELEASE,
Expand Down
Loading

0 comments on commit 075d15e

Please sign in to comment.