mirror of
https://github.com/filamentphp/plugin-skeleton.git
synced 2025-12-06 13:38:53 +08:00
remove PluginServiceProvider and configure updates
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev:styles": "npx tailwindcss -i resources/css/plugin.css -o resources/dist/skeleton.css --postcss --watch",
|
||||
"dev:styles": "npx tailwindcss -i config-stubs/theme/plugin.css -o resources/dist/skeleton.css --postcss --watch",
|
||||
"dev:scripts": "esbuild resources/js/plugin.js --bundle --sourcemap=inline --outfile=resources/dist/skeleton.js --watch",
|
||||
"build:styles": "npx tailwindcss -i resources/css/plugin.css -o resources/dist/skeleton.css --postcss --minify && npm run purge",
|
||||
"build:styles": "npx tailwindcss -i config-stubs/theme/plugin.css -o resources/dist/skeleton.css --postcss --minify && npm run purge",
|
||||
"build:scripts": "esbuild resources/js/plugin.js --bundle --minify --outfile=resources/dist/skeleton.js",
|
||||
"purge": "filament-purge -i resources/dist/skeleton.css -o resources/dist/skeleton.css",
|
||||
"dev": "npm-run-all --parallel dev:*",
|
||||
@@ -15,6 +15,7 @@
|
||||
"esbuild": "^0.8.57",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss-import": "^15.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"prettier-plugin-tailwindcss": "^0.1.13",
|
||||
"tailwindcss": "^3.2"
|
||||
15
configure-stubs/theme/package.json
Normal file
15
configure-stubs/theme/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npx tailwindcss -i config-stubs/theme/plugin.css -o resources/dist/skeleton.css --postcss --watch",
|
||||
"build": "npx tailwindcss -i config-stubs/theme/plugin.css -o resources/dist/skeleton.css --postcss --minify"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.7",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss-import": "^15.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"prettier-plugin-tailwindcss": "^0.1.13",
|
||||
"tailwindcss": "^3.2"
|
||||
}
|
||||
}
|
||||
1
configure-stubs/theme/plugin.css
Normal file
1
configure-stubs/theme/plugin.css
Normal file
@@ -0,0 +1 @@
|
||||
@import "../../vendor/filament/filament/resources/css/index.css";
|
||||
@@ -35,7 +35,7 @@ $useUpdateChangelogWorkflow = confirm('Use automatic changelog updater workflow?
|
||||
|
||||
$isTheme = confirm('Is this a custom theme?');
|
||||
$formsOnly = ! $isTheme && confirm('Is this for Forms only?');
|
||||
$tablesOnly = ! $formsOnly && confirm('Is this for Tables only?');
|
||||
$tablesOnly = ! ($isTheme || $formsOnly) && confirm('Is this for Tables only?');
|
||||
|
||||
writeln("\r");
|
||||
writeln('------');
|
||||
@@ -83,15 +83,23 @@ if ($formsOnly) {
|
||||
]);
|
||||
} else {
|
||||
if ($isTheme) {
|
||||
copy(__DIR__ . '/configure-stubs/theme/package.json', __DIR__ . '/package.json');
|
||||
copy(__DIR__ . '/configure-stubs/theme/plugin.css', __DIR__ . '/resources/css/plugin.css');
|
||||
safeUnlink(__DIR__ . '/src/SkeletonServiceProvider.php');
|
||||
remove_package_script(['purge']);
|
||||
remove_package_script(['dev:scripts']);
|
||||
remove_package_script(['build:scripts']);
|
||||
remove_package_script(['@awcodes/filament-plugin-purge']);
|
||||
remove_package_script(['esbuild']);
|
||||
replace_in_file(__DIR__.'/package.json', [' && npm run purge' => '']);
|
||||
safeUnlink(__DIR__ . '/src/Skeleton.php');
|
||||
removeDirectory(__DIR__ . '/config');
|
||||
removeDirectory(__DIR__ . '/database');
|
||||
removeDirectory(__DIR__ . '/stubs');
|
||||
removeDirectory(__DIR__ . '/resources/js');
|
||||
removeDirectory(__DIR__ . '/resources/lang');
|
||||
removeDirectory(__DIR__ . '/resources/views');
|
||||
removeDirectory(__DIR__ . '/src/Commands');
|
||||
removeDirectory(__DIR__ . '/src/Facades');
|
||||
removeDirectory(__DIR__ . '/src/Testing');
|
||||
} else {
|
||||
safeUnlink(__DIR__ . '/src/SkeletonTheme.php');
|
||||
copy(__DIR__ . '/configure-stubs/package/package.json', __DIR__ . '/package.json');
|
||||
copy(__DIR__ . '/configure-stubs/package/plugin.css', __DIR__ . '/resources/css/plugin.css');
|
||||
}
|
||||
|
||||
remove_composer_filament_deps([
|
||||
@@ -124,6 +132,7 @@ foreach ($files as $file) {
|
||||
str_contains($file, determineSeparator('src/SkeletonTheme.php')) => rename($file, determineSeparator('./src/'.$className.'Theme.php')),
|
||||
str_contains($file, determineSeparator('src/Facades/Skeleton.php')) => rename($file, determineSeparator('./src/Facades/'.$className.'.php')),
|
||||
str_contains($file, determineSeparator('src/Commands/SkeletonCommand.php')) => rename($file, determineSeparator('./src/Commands/'.$className.'Command.php')),
|
||||
str_contains($file, determineSeparator('src/Testing/TestsSkeleton.php')) => rename($file, determineSeparator('./src/Testing/Tests'.$className.'.php')),
|
||||
str_contains($file, determineSeparator('database/migrations/create_skeleton_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_'.$packageSlugWithoutPrefix.'_table.php.stub')),
|
||||
str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/'.$packageSlugWithoutPrefix.'.php')),
|
||||
str_contains($file, 'README.md') => remove_tag($file, 'delete'),
|
||||
@@ -174,7 +183,10 @@ if (! $useUpdateChangelogWorkflow) {
|
||||
|
||||
confirm('Execute `composer install` and run tests?') && run('composer install && composer test');
|
||||
|
||||
confirm('Let this script delete itself?', true) && unlink(__FILE__);
|
||||
if (confirm('Let this script delete itself?', true)) {
|
||||
removeDirectory(__DIR__ . '/configure-stubs');
|
||||
unlink(__FILE__);
|
||||
}
|
||||
|
||||
function ask(string $question, string $default = ''): string
|
||||
{
|
||||
@@ -362,3 +374,15 @@ function replaceForAllOtherOSes(): array
|
||||
{
|
||||
return explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|author@domain.com" --exclude-dir=vendor ./* ./.github/* | grep -v '.basename(__FILE__)));
|
||||
}
|
||||
|
||||
function removeDirectory($dir): void {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") removeDirectory($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
"postcss-import": {},
|
||||
"tailwindcss/nesting": {},
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
|
||||
@@ -2,44 +2,109 @@
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
|
||||
//use Filament\Support\Assets\Js;
|
||||
//use Filament\Support\Assets\Css;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Context;
|
||||
use Filament\PluginServiceProvider;
|
||||
use Filament\Support\Assets\AssetManager;
|
||||
use Filament\Support\Assets\Js;
|
||||
use Filament\Support\Assets\Css;
|
||||
use Filament\Support\Assets\Asset;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Support\Icons\Icon;
|
||||
use Filament\Support\Icons\IconManager;
|
||||
use Filament\Support\Assets\AlpineComponent;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Spatie\LaravelPackageTools\Package;
|
||||
//use Filament\Support\Assets\AlpineComponent;
|
||||
use Spatie\LaravelPackageTools\PackageServiceProvider;
|
||||
use Spatie\LaravelPackageTools\Commands\InstallCommand;
|
||||
use Livewire\Testing\TestableLivewire;
|
||||
use VendorName\Skeleton\Commands\SkeletonCommand;
|
||||
use VendorName\Skeleton\Testing\TestsSkeleton;
|
||||
|
||||
class SkeletonServiceProvider extends PluginServiceProvider
|
||||
class SkeletonServiceProvider extends PackageServiceProvider
|
||||
{
|
||||
public static string $name = 'skeleton';
|
||||
|
||||
public static string $viewNamespace = 'skeleton';
|
||||
|
||||
public function configurePackage(Package $package): void
|
||||
{
|
||||
$package->name(static::$name)
|
||||
->hasConfigFile()
|
||||
->hasViews()
|
||||
->hasMigration('create_skeleton_table')
|
||||
->hasCommand(SkeletonCommand::class);
|
||||
->hasCommands($this->getCommands())
|
||||
->hasInstallCommand(function(InstallCommand $command) {
|
||||
$command
|
||||
->publishConfigFile()
|
||||
->publishMigrations()
|
||||
->askToRunMigrations()
|
||||
->askToStarRepoOnGitHub(':vendor_slug/:package_slug');
|
||||
});
|
||||
|
||||
$configFileName = $package->shortName();
|
||||
|
||||
if (file_exists($this->package->basePath("/../config/{$configFileName}.php"))) {
|
||||
$package->hasConfigFile();
|
||||
}
|
||||
|
||||
if (file_exists($this->package->basePath('/../database/migrations'))) {
|
||||
$package->hasMigrations($this->getMigrations());
|
||||
}
|
||||
|
||||
if (file_exists($this->package->basePath('/../resources/lang'))) {
|
||||
$package->hasTranslations();
|
||||
}
|
||||
|
||||
if (file_exists($this->package->basePath('/../resources/views'))) {
|
||||
$package->hasViews(static::$viewNamespace);
|
||||
}
|
||||
}
|
||||
|
||||
public function packageRegistered(): void
|
||||
{
|
||||
parent::packageRegistered();
|
||||
|
||||
// Facade Registration
|
||||
$this->app->bind('skeleton', function (): Skeleton {
|
||||
return new Skeleton();
|
||||
});
|
||||
|
||||
// Context Registration
|
||||
$this->app->resolving('skeleton', function () {
|
||||
foreach ($this->getContexts() as $context) {
|
||||
Filament::registerContext($context);
|
||||
}
|
||||
});
|
||||
|
||||
// Asset Registration
|
||||
$this->app->resolving(AssetManager::class, function () {
|
||||
FilamentAsset::register($this->getAssets(), $this->getAssetPackage());
|
||||
FilamentAsset::registerScriptData($this->getScriptData(), $this->getAssetPackage());
|
||||
});
|
||||
|
||||
// Icon Registration
|
||||
$this->app->resolving(IconManager::class, function () {
|
||||
FilamentIcon::register($this->getIcons());
|
||||
});
|
||||
}
|
||||
|
||||
public function packageBooted(): void
|
||||
{
|
||||
parent::packageBooted();
|
||||
$this->registerMacros();
|
||||
|
||||
// Handle Stubs
|
||||
if ($this->app->runningInConsole()) {
|
||||
foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) {
|
||||
$this->publishes([
|
||||
$file->getRealPath() => base_path("stubs/skeleton/{$file->getFilename()}"),
|
||||
], 'forms-stubs');
|
||||
}
|
||||
}
|
||||
|
||||
// Testing
|
||||
TestableLivewire::mixin(new TestsSkeleton());
|
||||
}
|
||||
|
||||
protected function getAssetPackage(): ?string
|
||||
{
|
||||
return 'skeleton';
|
||||
return static::$name ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,8 +114,64 @@ class SkeletonServiceProvider extends PluginServiceProvider
|
||||
{
|
||||
return [
|
||||
// AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'),
|
||||
// Css::make('echo', __DIR__ . '/../resources/dist/skeleton.js'),
|
||||
// Js::make('echo', __DIR__ . '/../resources/dist/skeleton.js'),
|
||||
Css::make('skeleton-styles', __DIR__ . '/../resources/dist/skeleton.js'),
|
||||
Js::make('skeleton-scripts', __DIR__ . '/../resources/dist/skeleton.js'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string>
|
||||
*/
|
||||
protected function getCommands(): array
|
||||
{
|
||||
return [
|
||||
SkeletonCommand::class
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Context>
|
||||
*/
|
||||
protected function getContexts(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Icon>
|
||||
*/
|
||||
protected function getIcons(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
protected function getRoutes(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getScriptData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
protected function getMigrations(): array
|
||||
{
|
||||
return [
|
||||
'create_skeleton_table'
|
||||
];
|
||||
}
|
||||
|
||||
protected function registerMacros(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Filament;
|
||||
use Filament\Contracts\Plugin;
|
||||
use Filament\Support\Assets\Theme;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
use Filament\Support\Color;
|
||||
|
||||
class SkeletonTheme implements Plugin
|
||||
{
|
||||
@@ -20,6 +21,15 @@ class SkeletonTheme implements Plugin
|
||||
]);
|
||||
|
||||
$context
|
||||
->font('DM Sans')
|
||||
->primaryColor(Color::Amber)
|
||||
->secondaryColor(Color::Gray)
|
||||
->warningColor(Color::Amber)
|
||||
->dangerColor(Color::Rose)
|
||||
->successColor(Color::Green)
|
||||
->grayColor(Color::Slate)
|
||||
->sidebarWidth('20rem')
|
||||
->collapsedSidebarWidth('5.4rem')
|
||||
->theme('skeleton');
|
||||
}
|
||||
|
||||
|
||||
14
src/Testing/TestsSkeleton.php
Normal file
14
src/Testing/TestsSkeleton.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton\Testing;
|
||||
|
||||
use Illuminate\Testing\Assert;
|
||||
use Livewire\Testing\TestableLivewire;
|
||||
|
||||
/**
|
||||
* @mixin TestableLivewire
|
||||
*/
|
||||
class TestsSkeleton
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,21 +1,9 @@
|
||||
const colors = require('tailwindcss/colors')
|
||||
const preset = require('./vendor/filament/filament/tailwind.config.preset')
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: ['./resources/views/**/*.blade.php', './src/**/*.php'],
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
danger: colors.rose,
|
||||
primary: colors.amber,
|
||||
success: colors.green,
|
||||
warning: colors.amber,
|
||||
},
|
||||
},
|
||||
},
|
||||
presets: [preset],
|
||||
content: ['./resources/**/*.{blade.php,js}'],
|
||||
corePlugins: {
|
||||
preflight: false,
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user