Skip to content

Commit

Permalink
Merge pull request #6 from Cosnavel/feature/make-ready-for-laravel-9
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosnavel authored Feb 9, 2022
2 parents 27f959c + 78d9ef3 commit 5d6e8a4
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 32 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/composer-normalize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: normalize composer.json

on:
push:
paths:
- "composer.json"

jobs:
normalize:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2

- name: normalize composer.json
run: |
composer global require ergebnis/composer-normalize
composer normalize
- uses: stefanzweifel/[email protected]
with:
commit_message: normalize composer.json
8 changes: 5 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0]
laravel: [8.*]
php: [8.1, 8.0]
laravel: [8.*, 9.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: ^6.6
testbench: ^6.23
- laravel: 9.*
testbench: 7.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Update Changelog"

on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: main

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
44 changes: 26 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
{
"name": "cosnavel/laravel-query-localization",
"description": "Query String Localization Package for Laravel",
"license": "MIT",
"keywords": [
"Cosnavel",
"laravel",
"laravel-query-localization"
],
"homepage": "https://github.com/cosnavel/laravel-query-localization",
"license": "MIT",
"authors": [
{
"name": "Cosnavel",
"email": "[email protected]",
"role": "Developer"
}
],
"homepage": "https://github.com/cosnavel/laravel-query-localization",
"require": {
"php": "^8.0",
"illuminate/contracts": "^8.37",
"spatie/laravel-package-tools": "^1.4.3",
"timacdonald/has-parameters": "^1.2"
"illuminate/contracts": "^8.73 || ^9.0",
"spatie/laravel-package-tools": "^1.11"
},
"require-dev": {
"brianium/paratest": "^6.2",
"nunomaduro/collision": "^5.3",
"orchestra/testbench": "^6.15",
"livewire/livewire": "^2.10",
"nunomaduro/collision": "^5.3 || ^6.1",
"orchestra/testbench": "^6.23 || ^7.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.3",
"spatie/laravel-ray": "^1.23",
"vimeo/psalm": "^4.8"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Cosnavel\\LaravelQueryLocalization\\": "src",
Expand All @@ -40,24 +45,27 @@
"Cosnavel\\LaravelQueryLocalization\\Tests\\": "tests"
}
},
"scripts": {
"psalm": "vendor/bin/psalm",
"test": "./vendor/bin/testbench package:test --parallel --no-coverage",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"phpstan/extension-installer": true
},
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"Cosnavel\\LaravelQueryLocalization\\LaravelQueryLocalizationServiceProvider"
],
"aliases": {
"LaravelQueryLocalization": "Cosnavel\\LaravelQueryLocalization\\LaravelQueryLocalizationFacade"
}
},
"providers": [
"Cosnavel\\LaravelQueryLocalization\\LaravelQueryLocalizationServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"psalm": "vendor/bin/psalm",
"test": "./vendor/bin/testbench package:test --no-coverage",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
}
}
8 changes: 8 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: 5
paths:
- src
- config
- database
tmpDir: build/phpstan
checkMissingIterableValueType: false
5 changes: 2 additions & 3 deletions src/Macros/RouterMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ public function localize()
$translationRoutes[$lang] = trans($routeTranslationKey, [], $lang);
}


return $this->group([], function () use ($translationRoutes, $action, $routeName) {
foreach ($translationRoutes as $language => $translatedRoute) {
$this->group([
'prefix' => $translatedRoute, 'middleware' => LocaleFromQuery::with([
'translatedRoute' => $language,
]),
'prefix' => $translatedRoute, 'middleware' => LocaleFromQuery::class.":$language",
], function () use ($action, $routeName) {
$this->get('/', $action)->name($routeName);
});
Expand Down
3 changes: 0 additions & 3 deletions src/Middleware/LocaleFromQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use Closure;
use Cosnavel\LaravelQueryLocalization\Facades\LaravelQueryLocalization;
use Illuminate\Http\Request;
use TiMacDonald\Middleware\HasParameters;

class LocaleFromQuery
{
use HasParameters;

public function handle(Request $request, Closure $next, string $translatedRoute = null)
{
if ($request->get('locale')) {
Expand Down
7 changes: 2 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Cosnavel\LaravelQueryLocalization\LaravelQueryLocalizationServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

abstract class TestCase extends Orchestra
Expand All @@ -27,6 +28,7 @@ public function setUp(): void
protected function getPackageProviders($app)
{
return [
LivewireServiceProvider::class,
LaravelQueryLocalizationServiceProvider::class,
];
}
Expand All @@ -44,10 +46,5 @@ public function getEnvironmentSetUp($app)
'query-localization.useAcceptLanguageHeader' => true,
'query-localization.useUserLanguagePreference' => true,
]);

/*
include_once __DIR__.'/../database/migrations/create_laravel-query-localization_table.php.stub';
(new \CreatePackageTable())->up();
*/
}
}

0 comments on commit 5d6e8a4

Please sign in to comment.