Skip to content

Commit

Permalink
Base Route/URL (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet authored Oct 23, 2024
1 parent f875545 commit 83a5e9b
Show file tree
Hide file tree
Showing 116 changed files with 5,675 additions and 5,343 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ permissions:

jobs:
eslint:
name: ESLint Code Analysis
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[only-tests]') && !contains(github.event.head_commit.message, '[only-dusk]') && !contains(github.event.head_commit.message, '[ci-skip]') && !contains(github.event.head_commit.message, '[skip-ci]')"

timeout-minutes: 5

name: ESLint Code Analysis

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/php-quality-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: PHP Quality and Style

on:
push:
paths:
- ".github/workflows/phpstan.yml"
- "**.php"
- "phpstan.neon.dist"
- "rector.php"

jobs:
php-quality-style:
name: PHP Quality and Style
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
extensions: json, dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run Rector
run: composer refactor

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Refactor code with Rector

- name: Run Pint
run: composer format

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Format code with Pint

- name: Run PHPStan
run: composer analyse
105 changes: 49 additions & 56 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@ on:
- "**.jsx"
- "**.php"
- "**.vue"
- composer.json
- package-lock.json
- "demo-app/.env.example"
- "demo-app/composer.json"
- "demo-app/package.json"
- "demo-app/phpunit.xml.dist"
- "**/composer.json"
- "**/package-lock.json"
- "demo-app/{.env.example,phpunit.xml.dist}"
- ".github/workflows/tests.yml"

jobs:
tests:
name: Dusk Test Inertia ${{ matrix.inertia }} - Stack ${{ matrix.stack }}
timeout-minutes: 10
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[only-tests]') && !contains(github.event.head_commit.message, '[only-quality]') && !contains(github.event.head_commit.message, '[ci-skip]') && !contains(github.event.head_commit.message, '[skip-ci]')"

strategy:
fail-fast: true
matrix:
inertia: [v1, v2]
stack: [react, vue]

name: Tests

env:
APP_URL: "http://127.0.0.1:8000"
DB_CONNECTION: sqlite
Expand All @@ -37,27 +33,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql
coverage: none

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.dir }}
~/.npm
key: ${{ runner.os }}-${{ matrix.stack }}-${{ matrix.inertia }}-${{ hashFiles('**/composer.lock', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ matrix.stack }}-${{ matrix.inertia }}-
${{ runner.os }}-${{ matrix.stack }}-
${{ runner.os }}-
- name: Prepare The Environment
run: |
cd demo-app
Expand All @@ -72,11 +70,13 @@ jobs:
- name: Build React library
if: ${{ matrix.stack == 'react' }}
run: |
cd vue
npm install
# we need eslint-plugin-vue for files like helpers.js
cd vue
npm ci
npm install @inertiajs/vue3@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
cd ../react
npm install
npm ci
npm install @inertiajs/react@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
npm run build
# - name: Test React library
Expand All @@ -89,7 +89,8 @@ jobs:
if: ${{ matrix.stack == 'vue' }}
run: |
cd vue
npm install
npm ci
npm install @inertiajs/vue3@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
npm run build
- name: Test Vue library
Expand All @@ -102,52 +103,44 @@ jobs:
run: |
cd demo-app
composer install --no-progress --prefer-dist --optimize-autoloader
npm install
composer require inertiajs/inertia-laravel:${{ matrix.inertia == 'v1' && '^1.3' || '2.x-dev' }}
php artisan about
npm ci
npm install @inertiajs/react@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }} @inertiajs/vue3@${{ matrix.inertia == 'v1' && '1.2.0' || 'next' }}
npm install --install-links ../react
npm install --install-links ../vue
test -d node_modules/@inertiaui/modal-react || exit 1
test -d node_modules/@inertiaui/modal-vue || exit 1
npm run build
php artisan key:generate
touch database/database.sqlite
php artisan migrate --seed
php artisan migrate:fresh --seed
php artisan dusk:chrome-driver --detect
- name: Run HTTP server
- name: Run tests
run: |
cd demo-app
php artisan serve --no-reload &
php artisan test
- name: Start Chrome Driver
- name: Start servers
run: |
cd demo-app
php artisan serve --no-reload &
./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 &
- name: Run Dusk tests
run: |
cd demo-app
php artisan migrate:fresh --seed
php artisan dusk
- name: Upload Screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: screenshots
path: demo-app/tests/Browser/screenshots

- name: Upload Snapshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: snapshots
path: demo-app/tests/Browser/__snapshots__

- name: Upload Console Logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: console
path: demo-app/tests/Browser/console

- name: Upload Logs
- name: Upload artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: logs
path: demo-app/storage/logs
name: dusk-artifacts
path: |
demo-app/tests/Browser/screenshots
demo-app/tests/Browser/__snapshots__
demo-app/tests/Browser/console
demo-app/storage/logs
71 changes: 71 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "inertiaui/modal",
"description": "Inertia Modal",
"homepage": "https://github.com/inertiaui/modal",
"license": "MIT",
"require": {
"php": "^8.2",
"illuminate/contracts": "^10.48||^11.11",
"inertiajs/inertia-laravel": "^1.3|^2.0"
},
"require-dev": {
"larastan/larastan": "^2.9",
"laravel/pint": "^1.14",
"orchestra/testbench": "^8.23||^9.1",
"rector/rector": "^1.0.3"
},
"autoload": {
"psr-4": {
"InertiaUI\\Modal\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse --memory-limit=512M",
"format": "vendor/bin/pint",
"refactor": "vendor/bin/rector",
"eslint-react": "cd react && npm run eslint",
"eslint-vue": "cd vue && npm run eslint",
"build-react": "cd react && npm run build",
"build-vue": "cd vue && npm run build",
"all": [
"@analyse",
"@refactor",
"@format",
"@eslint-react",
"@eslint-vue"
],
"build": [
"@all",
"@build-react",
"@build-vue"
],
"update-react": "cd react && npm upgrade",
"update-vue": "cd vue && npm upgrade",
"update-demo-app": "cd demo-app && composer update && npm upgrade",
"update-all": [
"composer update",
"@update-react",
"@update-vue",
"@update-demo-app"
]
},
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true,
"pestphp/pest-plugin": false
}
},
"extra": {
"laravel": {
"providers": [
"InertiaUI\\Modal\\ModalServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
8 changes: 8 additions & 0 deletions config/inertiaui-modal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
/**
* Bind the \InertiaUI\Modal\Redirector class to the 'redirect' singleton.
*/
'bind_extended_redirector' => true,
];
1 change: 1 addition & 0 deletions demo-app/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
install-links=true
2 changes: 2 additions & 0 deletions demo-app/app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function share(Request $request): array
{
return [
...parent::share($request),
'navigate' => (bool) request()->query('navigate'),
'random' => rand(1, 100_000),
'users' => User::query()->orderBy('name')->get(),
'flash' => [
'message' => fn () => $request->session()->get('message'),
Expand Down
10 changes: 10 additions & 0 deletions demo-app/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Providers;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Support\Facades\File;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -20,6 +22,14 @@ public function register(): void
*/
public function boot(): void
{
if (app()->runningInConsole()) {
$installed = collect(File::json(base_path('vendor/composer/installed.json'))['packages'] ?? [])
->firstWhere('name', 'inertiajs/inertia-laravel');

AboutCommand::add('Inertia.js', 'Stack', config('app.stack') === 'vue' ? 'Vue.js' : 'React.js');
AboutCommand::add('Inertia.js', 'Version', $installed['version'] ?? 'Not installed');
}

Model::unguard();
}
}
9 changes: 8 additions & 1 deletion demo-app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "inertiaui/modal-demo-app",
"type": "project",
"description": "The Inertia Modal Demo App",
"license": "Commercial",
"license": "MIT",
"require": {
"php": "^8.2",
"guzzlehttp/guzzle": "^7.2",
"inertiajs/inertia-laravel": "^1.0",
"inertiaui/modal": "*",
"laravel/framework": "^10.48|^11.11",
"laravel/sanctum": "^3.2|^4.0",
"laravel/tinker": "^2.8",
Expand All @@ -20,6 +21,12 @@
"nunomaduro/collision": "^7.0|^8.0",
"phpunit/phpunit": "^10.0"
},
"repositories": [
{
"url": "./../",
"type": "path"
}
],
"autoload": {
"psr-4": {
"App\\": "app/",
Expand Down
Loading

0 comments on commit 83a5e9b

Please sign in to comment.