updates for Filament v4

This commit is contained in:
Adam Weston
2025-06-21 11:19:47 -04:00
parent 93d46d196d
commit c2645897dd
18 changed files with 110 additions and 84 deletions

View File

@@ -22,6 +22,6 @@ jobs:
uses: aglipanci/laravel-pint-action@2.4 uses: aglipanci/laravel-pint-action@2.4
- name: Commit changes - name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5 uses: stefanzweifel/git-auto-commit-action@v6
with: with:
commit_message: Fix styling commit_message: Fix styling

View File

@@ -16,7 +16,7 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.1' php-version: '8.2'
coverage: none coverage: none
- name: Install composer dependencies - name: Install composer dependencies

View File

@@ -1,4 +1,4 @@
name: run-tests name: "Run Tests"
on: on:
push: push:
@@ -13,19 +13,18 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2, 8.1] php: [8.4, 8.3, 8.2]
laravel: [11.*, 10.*] laravel: [12.*, 11.*]
stability: [prefer-lowest, prefer-stable] stability: [prefer-lowest, prefer-stable]
include: include:
- laravel: 10.* - laravel: 12.*
testbench: 8.* testbench: 10.*
carbon: 2.* carbon: 3.*
collision: 8.*
- laravel: 11.* - laravel: 11.*
testbench: 9.* testbench: 9.*
carbon: 3.* carbon: 3.*
exclude: collision: 8.*
- laravel: 11.*
php: 8.1
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
.DS_Store **/.DS_Store
.idea .idea
.phpunit.result.cache .phpunit.result.cache
.phpunit.cache
.vscode .vscode
build build
composer.lock composer.lock

View File

@@ -25,6 +25,15 @@ You can install the package via composer:
composer require :vendor_slug/:package_slug composer require :vendor_slug/:package_slug
``` ```
> [!IMPORTANT]
> If you have not set up a custom theme and are using Filament Panels follow the instructions in the [Filament Docs](https://filamentphp.com/docs/4.x/styling/overview#creating-a-custom-theme) first.
After setting up a custom theme add the plugin's views to your theme css file or your app's css file if using the standalone packages.
```css
@source '../../../../vendor/:vendor_slug/:package_slug/resources/**/*.blade.php';
```
You can publish and run the migrations with: You can publish and run the migrations with:
```bash ```bash

View File

@@ -47,4 +47,6 @@ compile({
...defaultOptions, ...defaultOptions,
entryPoints: ['./resources/js/index.js'], entryPoints: ['./resources/js/index.js'],
outfile: './resources/dist/skeleton.js', outfile: './resources/dist/skeleton.js',
}).then(() => {
console.log(`Build completed for skeleton.js`)
}) })

View File

@@ -21,23 +21,25 @@
} }
], ],
"require": { "require": {
"php": "^8.1", "php": "^8.2",
"filament/filament": "^3.0", "filament/filament": "^4.0",
"filament/forms": "^3.0", "filament/forms": "^4.0",
"filament/tables": "^3.0", "filament/tables": "^4.0",
"spatie/laravel-package-tools": "^1.15.0" "spatie/laravel-package-tools": "^1.15.0"
}, },
"require-dev": { "require-dev": {
"larastan/larastan": "^2.0", "larastan/larastan": "^3.0",
"laravel/pint": "^1.0", "laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9|^8.0", "nunomaduro/collision": "^8.0",
"orchestra/testbench": "^8.0|^9.0", "orchestra/testbench": "^9.0|^10.0",
"pestphp/pest": "^2.1", "pestphp/pest": "^3.0",
"pestphp/pest-plugin-arch": "^2.0", "pestphp/pest-plugin-arch": "^3.0",
"pestphp/pest-plugin-laravel": "^2.0", "pestphp/pest-plugin-laravel": "^3.0",
"pestphp/pest-plugin-livewire": "^3.0",
"phpstan/extension-installer": "^1.1", "phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-phpunit": "^2.0",
"rector/rector": "^2.0",
"spatie/laravel-ray": "^1.26" "spatie/laravel-ray": "^1.26"
}, },
"autoload": { "autoload": {
@@ -53,17 +55,12 @@
}, },
"scripts": { "scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse", "analyse": "phpstan analyse",
"test": "vendor/bin/pest", "lint": "pint",
"test-coverage": "vendor/bin/pest --coverage", "refactor": "rector",
"format": "vendor/bin/pint" "test": "pest",
}, "test:lint": "pint --test",
"config": { "test:refactor": "rector --dry-run"
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
}, },
"extra": { "extra": {
"laravel": { "laravel": {
@@ -75,6 +72,14 @@
} }
} }
}, },
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true "prefer-stable": true
} }

View File

@@ -35,6 +35,7 @@ $usePhpStan = confirm('Enable PhpStan?', true);
$usePint = confirm('Enable Pint?', true); $usePint = confirm('Enable Pint?', true);
$useDependabot = confirm('Enable Dependabot?', true); $useDependabot = confirm('Enable Dependabot?', true);
$useLaravelRay = confirm('Enable Ray?', true); $useLaravelRay = confirm('Enable Ray?', true);
$useRector = confirm('Enable Rector?', true);
$useUpdateChangelogWorkflow = confirm('Use automatic changelog updater workflow?', true); $useUpdateChangelogWorkflow = confirm('Use automatic changelog updater workflow?', true);
$isTheme = confirm('Is this a custom theme?'); $isTheme = confirm('Is this a custom theme?');
@@ -54,6 +55,7 @@ writeln('Larastan/PhpStan : ' . ($usePhpStan ? "\e[0;32mYes" : "\e[0;31mNo") .
writeln('Pint : ' . ($usePint ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); writeln('Pint : ' . ($usePint ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
writeln('Use Dependabot : ' . ($useDependabot ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); writeln('Use Dependabot : ' . ($useDependabot ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
writeln('Use Ray : ' . ($useLaravelRay ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); writeln('Use Ray : ' . ($useLaravelRay ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
writeln('Use Rector : ' . ($useRector ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
writeln('Auto-Changelog : ' . ($useUpdateChangelogWorkflow ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); writeln('Auto-Changelog : ' . ($useUpdateChangelogWorkflow ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
if ($formsOnly) { if ($formsOnly) {
writeln("Filament/Forms : \e[0;32mYes\e[0m"); writeln("Filament/Forms : \e[0;32mYes\e[0m");
@@ -169,7 +171,7 @@ if (! $usePhpStan) {
'phpstan/extension-installer', 'phpstan/extension-installer',
'phpstan/phpstan-deprecation-rules', 'phpstan/phpstan-deprecation-rules',
'phpstan/phpstan-phpunit', 'phpstan/phpstan-phpunit',
'nunomaduro/larastan', 'larastan/larastan',
], 'require-dev'); ], 'require-dev');
removeComposerDeps(['analyse'], 'scripts'); removeComposerDeps(['analyse'], 'scripts');
@@ -186,8 +188,19 @@ if (! $usePint) {
removeComposerDeps(['format'], 'scripts'); removeComposerDeps(['format'], 'scripts');
} }
if (! $useRector) {
safeUnlink(__DIR__ . '/rector.php');
removeComposerDeps([
'rector/rector',
], 'require-dev');
removeComposerDeps(['refactor', 'test:refactor', ], 'scripts');
}
if (! $useUpdateChangelogWorkflow) { if (! $useUpdateChangelogWorkflow) {
safeUnlink(__DIR__ . '/.github/workflows/update-changelog.yml'); safeUnlink(__DIR__ . '/.github/workflows/update-changelog.yml');
safeUnlink(__DIR__ . '/CHANGELOG.md');
} }
confirm('Execute `composer install`?') && run('composer install'); confirm('Execute `composer install`?') && run('composer install');

View File

@@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
public function up() public function up(): void
{ {
Schema::create('migration_table_name_table', function (Blueprint $table) { Schema::create('migration_table_name_table', function (Blueprint $table) {
$table->id(); $table->id();

View File

@@ -2,25 +2,11 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/skeleton.css --postcss --watch", "dev": "node bin/build.js --dev",
"dev:scripts": "node bin/build.js --dev", "build": "node bin/build.js"
"build:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/skeleton.css --postcss --minify && npm run purge",
"build:scripts": "node bin/build.js",
"purge": "filament-purge -i resources/dist/skeleton.css -o resources/dist/skeleton.css -v 3.x",
"dev": "npm-run-all --parallel dev:*",
"build": "npm-run-all build:*"
}, },
"devDependencies": { "devDependencies": {
"@awcodes/filament-plugin-purge": "^1.1.1", "esbuild": "^0.25.5",
"@tailwindcss/forms": "^0.5.4", "prettier": "^3.5.3"
"@tailwindcss/typography": "^0.5.9",
"autoprefixer": "^10.4.14",
"esbuild": "^0.19.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.26",
"postcss-import": "^15.1.0",
"prettier": "^2.7.1",
"prettier-plugin-tailwindcss": "^0.1.13",
"tailwindcss": "^3.3.3"
} }
} }

View File

@@ -1,4 +1,6 @@
includes: includes:
- vendor/larastan/larastan/extension.neon
- vendor/nesbot/carbon/extension.neon
- phpstan-baseline.neon - phpstan-baseline.neon
parameters: parameters:
@@ -10,5 +12,4 @@ parameters:
tmpDir: build/phpstan tmpDir: build/phpstan
checkOctaneCompatibility: true checkOctaneCompatibility: true
checkModelProperties: true checkModelProperties: true
checkMissingIterableValueType: false

View File

@@ -1,8 +0,0 @@
module.exports = {
plugins: {
"postcss-import": {},
"tailwindcss/nesting": {},
tailwindcss: {},
autoprefixer: {},
},
}

17
rector.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
privatization: true,
earlyReturn: true,
strictBooleans: true,
)
->withPhpSets();

View File

@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Facade;
*/ */
class Skeleton extends Facade class Skeleton extends Facade
{ {
protected static function getFacadeAccessor() protected static function getFacadeAccessor(): string
{ {
return \VendorName\Skeleton\Skeleton::class; return \VendorName\Skeleton\Skeleton::class;
} }

View File

@@ -103,8 +103,8 @@ class SkeletonServiceProvider extends PackageServiceProvider
{ {
return [ return [
// AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'), // AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'),
Css::make('skeleton-styles', __DIR__ . '/../resources/dist/skeleton.css'), // Css::make('skeleton-styles', __DIR__ . '/../resources/dist/skeleton.css'),
Js::make('skeleton-scripts', __DIR__ . '/../resources/dist/skeleton.js'), // Js::make('skeleton-scripts', __DIR__ . '/../resources/dist/skeleton.js'),
]; ];
} }

View File

@@ -1,10 +0,0 @@
const preset = require('./vendor/filament/filament/tailwind.config.preset')
module.exports = {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
}

View File

@@ -9,17 +9,23 @@ use Filament\FilamentServiceProvider;
use Filament\Forms\FormsServiceProvider; use Filament\Forms\FormsServiceProvider;
use Filament\Infolists\InfolistsServiceProvider; use Filament\Infolists\InfolistsServiceProvider;
use Filament\Notifications\NotificationsServiceProvider; use Filament\Notifications\NotificationsServiceProvider;
use Filament\Schemas\SchemasServiceProvider;
use Filament\Support\SupportServiceProvider; use Filament\Support\SupportServiceProvider;
use Filament\Tables\TablesServiceProvider; use Filament\Tables\TablesServiceProvider;
use Filament\Widgets\WidgetsServiceProvider; use Filament\Widgets\WidgetsServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Livewire\LivewireServiceProvider; use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as Orchestra; use Orchestra\Testbench\TestCase as Orchestra;
use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider; use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider;
use VendorName\Skeleton\SkeletonServiceProvider; use VendorName\Skeleton\SkeletonServiceProvider;
class TestCase extends Orchestra class TestCase extends Orchestra
{ {
use LazilyRefreshDatabase;
use WithWorkbench;
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
@@ -31,7 +37,7 @@ class TestCase extends Orchestra
protected function getPackageProviders($app) protected function getPackageProviders($app)
{ {
return [ $providers = [
ActionsServiceProvider::class, ActionsServiceProvider::class,
BladeCaptureDirectiveServiceProvider::class, BladeCaptureDirectiveServiceProvider::class,
BladeHeroiconsServiceProvider::class, BladeHeroiconsServiceProvider::class,
@@ -41,20 +47,25 @@ class TestCase extends Orchestra
InfolistsServiceProvider::class, InfolistsServiceProvider::class,
LivewireServiceProvider::class, LivewireServiceProvider::class,
NotificationsServiceProvider::class, NotificationsServiceProvider::class,
SchemasServiceProvider::class,
SupportServiceProvider::class, SupportServiceProvider::class,
TablesServiceProvider::class, TablesServiceProvider::class,
WidgetsServiceProvider::class, WidgetsServiceProvider::class,
SkeletonServiceProvider::class, SkeletonServiceProvider::class,
]; ];
sort($providers);
return $providers;
} }
public function getEnvironmentSetUp($app) public function getEnvironmentSetUp($app): void
{ {
config()->set('database.default', 'testing'); $app['config']->set('database.default', 'testing');
}
/* protected function defineDatabaseMigrations(): void
$migration = include __DIR__.'/../database/migrations/create_skeleton_table.php.stub'; {
$migration->up(); $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
*/
} }
} }