configured plugin
This commit is contained in:
parent
2b156878ad
commit
400cee47fc
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@ -1 +1 @@
|
||||
github: :vendor_name
|
||||
github: AlexanderGabriel
|
||||
|
||||
6
.github/ISSUE_TEMPLATE/config.yml
vendored
6
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,11 +1,11 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Ask a question
|
||||
url: https://github.com/:vendor_name/:package_name/discussions/new?category=q-a
|
||||
url: https://github.com/AlexanderGabriel/filament-oauth2/discussions/new?category=q-a
|
||||
about: Ask the community for help
|
||||
- name: Request a feature
|
||||
url: https://github.com/:vendor_name/:package_name/discussions/new?category=ideas
|
||||
url: https://github.com/AlexanderGabriel/filament-oauth2/discussions/new?category=ideas
|
||||
about: Share ideas for new features
|
||||
- name: Report a security issue
|
||||
url: https://github.com/:vendor_name/:package_name/security/policy
|
||||
url: https://github.com/AlexanderGabriel/filament-oauth2/security/policy
|
||||
about: Learn how to notify us for sensitive bugs
|
||||
|
||||
2
.github/SECURITY.md
vendored
2
.github/SECURITY.md
vendored
@ -1,3 +1,3 @@
|
||||
# Security Policy
|
||||
|
||||
If you discover any security related issues, please email author@domain.com instead of using the issue tracker.
|
||||
If you discover any security related issues, please email alexander.gabriel@digital-infinity.de instead of using the issue tracker.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `:package_name` will be documented in this file.
|
||||
All notable changes to `filament-oauth2` will be documented in this file.
|
||||
|
||||
## 1.0.0 - 202X-XX-XX
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) :vendor_name <author@domain.com>
|
||||
Copyright (c) AlexanderGabriel <alexander.gabriel@digital-infinity.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
32
README.md
32
README.md
@ -1,19 +1,11 @@
|
||||
# :package_description
|
||||
# This is my package filament-oauth2
|
||||
|
||||
[](https://packagist.org/packages/:vendor_slug/:package_slug)
|
||||
[](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3Arun-tests+branch%3Amain)
|
||||
[](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain)
|
||||
[](https://packagist.org/packages/:vendor_slug/:package_slug)
|
||||
[](https://packagist.org/packages/alexandergabriel/filament-oauth2)
|
||||
[](https://github.com/alexandergabriel/filament-oauth2/actions?query=workflow%3Arun-tests+branch%3Amain)
|
||||
[](https://github.com/alexandergabriel/filament-oauth2/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain)
|
||||
[](https://packagist.org/packages/alexandergabriel/filament-oauth2)
|
||||
|
||||
<!--delete-->
|
||||
---
|
||||
This repo can be used to scaffold a Filament plugin. Follow these steps to get started:
|
||||
|
||||
1. Press the "Use this template" button at the top of this repo to create a new repo with the contents of this skeleton.
|
||||
2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files.
|
||||
3. Make something great!
|
||||
---
|
||||
<!--/delete-->
|
||||
|
||||
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
|
||||
|
||||
@ -22,26 +14,26 @@ This is where your description should go. Limit it to a paragraph or two. Consid
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require :vendor_slug/:package_slug
|
||||
composer require alexandergabriel/filament-oauth2
|
||||
```
|
||||
|
||||
You can publish and run the migrations with:
|
||||
|
||||
```bash
|
||||
php artisan vendor:publish --tag=":package_slug-migrations"
|
||||
php artisan vendor:publish --tag="filament-oauth2-migrations"
|
||||
php artisan migrate
|
||||
```
|
||||
|
||||
You can publish the config file with:
|
||||
|
||||
```bash
|
||||
php artisan vendor:publish --tag=":package_slug-config"
|
||||
php artisan vendor:publish --tag="filament-oauth2-config"
|
||||
```
|
||||
|
||||
Optionally, you can publish the views using
|
||||
|
||||
```bash
|
||||
php artisan vendor:publish --tag=":package_slug-views"
|
||||
php artisan vendor:publish --tag="filament-oauth2-views"
|
||||
```
|
||||
|
||||
This is the contents of the published config file:
|
||||
@ -54,8 +46,8 @@ return [
|
||||
## Usage
|
||||
|
||||
```php
|
||||
$variable = new VendorName\Skeleton();
|
||||
echo $variable->echoPhrase('Hello, VendorName!');
|
||||
$filamentOauth2 = new AlexanderGabriel\FilamentOauth2();
|
||||
echo $filamentOauth2->echoPhrase('Hello, AlexanderGabriel!');
|
||||
```
|
||||
|
||||
## Testing
|
||||
@ -78,7 +70,7 @@ Please review [our security policy](../../security/policy) on how to report secu
|
||||
|
||||
## Credits
|
||||
|
||||
- [:author_name](https://github.com/:author_username)
|
||||
- [Alexander Gabriel](https://github.com/AlexanderGabriel)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## License
|
||||
|
||||
@ -46,5 +46,5 @@ const defaultOptions = {
|
||||
compile({
|
||||
...defaultOptions,
|
||||
entryPoints: ['./resources/js/index.js'],
|
||||
outfile: './resources/dist/skeleton.js',
|
||||
outfile: './resources/dist/filament-oauth2.js',
|
||||
})
|
||||
|
||||
@ -1,29 +1,27 @@
|
||||
{
|
||||
"name": ":vendor_slug/:package_slug",
|
||||
"description": ":package_description",
|
||||
"name": "alexandergabriel/filament-oauth2",
|
||||
"description": "This is my package filament-oauth2",
|
||||
"keywords": [
|
||||
":vendor_name",
|
||||
"AlexanderGabriel",
|
||||
"laravel",
|
||||
":package_slug"
|
||||
"filament-oauth2"
|
||||
],
|
||||
"homepage": "https://github.com/:vendor_slug/:package_slug",
|
||||
"homepage": "https://github.com/alexandergabriel/filament-oauth2",
|
||||
"support": {
|
||||
"issues": "https://github.com/:vendor_slug/:package_slug/issues",
|
||||
"source": "https://github.com/:vendor_slug/:package_slug"
|
||||
"issues": "https://github.com/alexandergabriel/filament-oauth2/issues",
|
||||
"source": "https://github.com/alexandergabriel/filament-oauth2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": ":author_name",
|
||||
"email": "author@domain.com",
|
||||
"name": "Alexander Gabriel",
|
||||
"email": "alexander.gabriel@digital-infinity.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"filament/filament": "^3.0",
|
||||
"filament/forms": "^3.0",
|
||||
"filament/tables": "^3.0",
|
||||
"spatie/laravel-package-tools": "^1.15.0"
|
||||
},
|
||||
"require-dev": {
|
||||
@ -41,13 +39,13 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"VendorName\\Skeleton\\": "src/",
|
||||
"VendorName\\Skeleton\\Database\\Factories\\": "database/factories/"
|
||||
"AlexanderGabriel\\FilamentOauth2\\": "src/",
|
||||
"AlexanderGabriel\\FilamentOauth2\\Database\\Factories\\": "database/factories/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"VendorName\\Skeleton\\Tests\\": "tests/"
|
||||
"AlexanderGabriel\\FilamentOauth2\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@ -67,13 +65,13 @@
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"VendorName\\Skeleton\\SkeletonServiceProvider"
|
||||
"AlexanderGabriel\\FilamentOauth2\\FilamentOauth2ServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton"
|
||||
"FilamentOauth2": "AlexanderGabriel\\FilamentOauth2\\Facades\\FilamentOauth2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
}
|
||||
6
config/oauth2.php
Normal file
6
config/oauth2.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// config for AlexanderGabriel/FilamentOauth2
|
||||
return [
|
||||
|
||||
];
|
||||
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
// config for VendorName/Skeleton
|
||||
return [
|
||||
|
||||
];
|
||||
370
configure.php
370
configure.php
@ -1,370 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
$gitName = run('git config user.name');
|
||||
$authorName = ask('Author name', $gitName);
|
||||
|
||||
$gitEmail = run('git config user.email');
|
||||
$authorEmail = ask('Author email', $gitEmail);
|
||||
|
||||
$usernameGuess = explode(':', run('git config remote.origin.url'))[1] ?? '';
|
||||
if ($usernameGuess !== '') {
|
||||
$usernameGuess = dirname($usernameGuess);
|
||||
$usernameGuess = basename($usernameGuess);
|
||||
}
|
||||
$authorUsername = ask('Author username', $usernameGuess);
|
||||
|
||||
$vendorName = ask('Vendor name', $authorUsername);
|
||||
$vendorSlug = slugify($vendorName);
|
||||
$vendorNamespace = str_replace('-', '', ucwords($vendorName));
|
||||
$vendorNamespace = ask('Vendor namespace', $vendorNamespace);
|
||||
|
||||
$currentDirectory = getcwd();
|
||||
$folderName = basename($currentDirectory);
|
||||
|
||||
$packageName = ask('Package name', $folderName);
|
||||
$packageSlug = slugify($packageName);
|
||||
$packageSlugWithoutPrefix = removePrefix('filament-', $packageSlug);
|
||||
|
||||
$className = titleCase($packageName);
|
||||
$className = ask('Class name', $className);
|
||||
$variableName = lcfirst($className);
|
||||
$description = ask('Package description', "This is my package $packageSlug");
|
||||
|
||||
$usePhpStan = confirm('Enable PhpStan?', true);
|
||||
$usePint = confirm('Enable Pint?', true);
|
||||
$useDependabot = confirm('Enable Dependabot?', true);
|
||||
$useLaravelRay = confirm('Enable Ray?', true);
|
||||
$useUpdateChangelogWorkflow = confirm('Use automatic changelog updater workflow?', true);
|
||||
|
||||
$isTheme = confirm('Is this a custom theme?');
|
||||
$formsOnly = ! $isTheme && confirm('Is this for Forms only?');
|
||||
$tablesOnly = ! ($isTheme || $formsOnly) && confirm('Is this for Tables only?');
|
||||
|
||||
writeln("\r");
|
||||
writeln('------');
|
||||
writeln("Author : \e[0;36m$authorName ($authorUsername, $authorEmail)\e[0m");
|
||||
writeln("Vendor : \e[0;36m$vendorName ($vendorSlug)\e[0m");
|
||||
writeln('Package : ' . "\e[0;36m" . $packageSlug . ($description ? " <{$description}>" : '') . "\e[0m");
|
||||
writeln("Namespace : \e[0;36m$vendorNamespace\\$className\e[0m");
|
||||
writeln("Class name : \e[0;36m$className\e[0m");
|
||||
writeln('---');
|
||||
writeln("\e[1;37mPackages & Utilities\e[0m");
|
||||
writeln('Larastan/PhpStan : ' . ($usePhpStan ? "\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 Ray : ' . ($useLaravelRay ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
|
||||
writeln('Auto-Changelog : ' . ($useUpdateChangelogWorkflow ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m");
|
||||
if ($formsOnly) {
|
||||
writeln("Filament/Forms : \e[0;32mYes\e[0m");
|
||||
} elseif ($tablesOnly) {
|
||||
writeln("Filament/Tables : \e[0;32mYes\e[0m");
|
||||
} else {
|
||||
writeln("Filament/Filament : \e[0;32mYes\e[0m");
|
||||
}
|
||||
writeln('------');
|
||||
writeln("\r");
|
||||
writeln('This script will replace the above values in all relevant files in the project directory.');
|
||||
writeln("\r");
|
||||
|
||||
if (! confirm('Modify files?', true)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ($formsOnly) {
|
||||
safeUnlink(__DIR__ . '/src/SkeletonTheme.php');
|
||||
safeUnlink(__DIR__ . '/src/SkeletonPlugin.php');
|
||||
|
||||
removeComposerDeps([
|
||||
'filament/filament',
|
||||
'filament/tables',
|
||||
], 'require');
|
||||
} elseif ($tablesOnly) {
|
||||
safeUnlink(__DIR__ . '/src/SkeletonTheme.php');
|
||||
safeUnlink(__DIR__ . '/src/SkeletonPlugin.php');
|
||||
|
||||
removeComposerDeps([
|
||||
'filament/filament',
|
||||
'filament/forms',
|
||||
], 'require');
|
||||
} else {
|
||||
if ($isTheme) {
|
||||
safeUnlink(__DIR__ . '/src/SkeletonServiceProvider.php');
|
||||
safeUnlink(__DIR__ . '/src/SkeletonPlugin.php');
|
||||
safeUnlink(__DIR__ . '/src/Skeleton.php');
|
||||
removeDirectory(__DIR__ . '/bin');
|
||||
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');
|
||||
|
||||
setupPackageJsonForTheme();
|
||||
|
||||
} else {
|
||||
safeUnlink(__DIR__ . '/src/SkeletonTheme.php');
|
||||
}
|
||||
|
||||
removeComposerDeps([
|
||||
'filament/forms',
|
||||
'filament/tables',
|
||||
], 'require');
|
||||
}
|
||||
|
||||
$files = (str_starts_with(strtoupper(PHP_OS), 'WIN') ? replaceForWindows() : replaceForAllOtherOSes());
|
||||
|
||||
foreach ($files as $file) {
|
||||
replaceInFile($file, [
|
||||
':author_name' => $authorName,
|
||||
':author_username' => $authorUsername,
|
||||
'author@domain.com' => $authorEmail,
|
||||
':vendor_name' => $vendorName,
|
||||
':vendor_slug' => $vendorSlug,
|
||||
'VendorName' => $vendorNamespace,
|
||||
':package_name' => $packageName,
|
||||
':package_slug' => $packageSlug,
|
||||
':package_slug_without_prefix' => $packageSlugWithoutPrefix,
|
||||
'Skeleton' => $className,
|
||||
'skeleton' => $packageSlug,
|
||||
'migration_table_name' => titleSnake($packageSlug),
|
||||
'variable' => $variableName,
|
||||
':package_description' => $description,
|
||||
]);
|
||||
|
||||
match (true) {
|
||||
str_contains($file, determineSeparator('src/Skeleton.php')) => rename($file, determineSeparator('./src/' . $className . '.php')),
|
||||
str_contains($file, determineSeparator('src/SkeletonServiceProvider.php')) => rename($file, determineSeparator('./src/' . $className . 'ServiceProvider.php')),
|
||||
str_contains($file, determineSeparator('src/SkeletonTheme.php')) => rename($file, determineSeparator('./src/' . $className . (str_ends_with($className, 'Theme') ? '.php' : 'Theme.php'))),
|
||||
str_contains($file, determineSeparator('src/SkeletonPlugin.php')) => rename($file, determineSeparator('./src/' . $className . 'Plugin.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_' . titleSnake($packageSlugWithoutPrefix) . '_table.php.stub')),
|
||||
str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/' . $packageSlugWithoutPrefix . '.php')),
|
||||
str_contains($file, determineSeparator('resources/lang/en/skeleton.php')) => rename($file, determineSeparator('./resources/lang/en/' . $packageSlugWithoutPrefix . '.php')),
|
||||
str_contains($file, 'README.md') => removeTag($file, 'delete'),
|
||||
default => [],
|
||||
};
|
||||
}
|
||||
|
||||
if (! $useDependabot) {
|
||||
safeUnlink(__DIR__ . '/.github/dependabot.yml');
|
||||
safeUnlink(__DIR__ . '/.github/workflows/dependabot-auto-merge.yml');
|
||||
}
|
||||
|
||||
if (! $useLaravelRay) {
|
||||
removeComposerDeps(['spatie/laravel-ray'], 'require-dev');
|
||||
}
|
||||
|
||||
if (! $usePhpStan) {
|
||||
safeUnlink(__DIR__ . '/phpstan.neon.dist');
|
||||
safeUnlink(__DIR__ . '/phpstan-baseline.neon');
|
||||
safeUnlink(__DIR__ . '/.github/workflows/phpstan.yml');
|
||||
|
||||
removeComposerDeps([
|
||||
'phpstan/extension-installer',
|
||||
'phpstan/phpstan-deprecation-rules',
|
||||
'phpstan/phpstan-phpunit',
|
||||
'nunomaduro/larastan',
|
||||
], 'require-dev');
|
||||
|
||||
removeComposerDeps(['analyse'], 'scripts');
|
||||
}
|
||||
|
||||
if (! $usePint) {
|
||||
safeUnlink(__DIR__ . '/.github/workflows/fix-php-code-style-issues.yml');
|
||||
safeUnlink(__DIR__ . '/pint.json');
|
||||
|
||||
removeComposerDeps([
|
||||
'laravel/pint',
|
||||
], 'require-dev');
|
||||
|
||||
removeComposerDeps(['format'], 'scripts');
|
||||
}
|
||||
|
||||
if (! $useUpdateChangelogWorkflow) {
|
||||
safeUnlink(__DIR__ . '/.github/workflows/update-changelog.yml');
|
||||
}
|
||||
|
||||
confirm('Execute `composer install`?') && run('composer install');
|
||||
|
||||
if (confirm('Let this script delete itself?', true)) {
|
||||
unlink(__FILE__);
|
||||
}
|
||||
|
||||
function ask(string $question, string $default = ''): string
|
||||
{
|
||||
$def = $default ? "\e[0;33m ($default)" : '';
|
||||
$answer = readline("\e[0;32m" . $question . $def . ": \e[0m");
|
||||
|
||||
if (! $answer) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $answer;
|
||||
}
|
||||
|
||||
function confirm(string $question, bool $default = false): bool
|
||||
{
|
||||
$answer = ask($question, ($default ? 'Y/n' : 'y/N'));
|
||||
|
||||
if (strtolower($answer) === 'y/n') {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return strtolower($answer) === 'y';
|
||||
}
|
||||
|
||||
function writeln(string $line): void
|
||||
{
|
||||
echo $line . PHP_EOL;
|
||||
}
|
||||
|
||||
function run(string $command): string
|
||||
{
|
||||
return trim((string) shell_exec($command));
|
||||
}
|
||||
|
||||
function slugify(string $subject): string
|
||||
{
|
||||
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $subject), '-'));
|
||||
}
|
||||
|
||||
function titleCase(string $subject): string
|
||||
{
|
||||
return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $subject)));
|
||||
}
|
||||
|
||||
function titleSnake(string $subject, string $replace = '_'): string
|
||||
{
|
||||
return str_replace(['-', '_'], $replace, $subject);
|
||||
}
|
||||
|
||||
function replaceInFile(string $file, array $replacements): void
|
||||
{
|
||||
$contents = file_get_contents($file);
|
||||
|
||||
file_put_contents(
|
||||
$file,
|
||||
str_replace(
|
||||
array_keys($replacements),
|
||||
array_values($replacements),
|
||||
$contents
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function removePrefix(string $prefix, string $content): string
|
||||
{
|
||||
if (str_starts_with($content, $prefix)) {
|
||||
return substr($content, strlen($prefix));
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function removeComposerDeps(array $names, string $location): void
|
||||
{
|
||||
$data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true);
|
||||
|
||||
foreach ($data[$location] as $name => $version) {
|
||||
if (in_array($name, $names, true)) {
|
||||
unset($data[$location][$name]);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
function removeNpmDeps(array $names, string $location): void
|
||||
{
|
||||
$data = json_decode(file_get_contents(__DIR__ . '/package.json'), true);
|
||||
|
||||
foreach ($data[$location] as $name => $version) {
|
||||
if (in_array($name, $names, true)) {
|
||||
unset($data[$location][$name]);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(__DIR__ . '/package.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES |
|
||||
JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
function removeTag(string $file, string $tag): void
|
||||
{
|
||||
$contents = file_get_contents($file);
|
||||
|
||||
file_put_contents(
|
||||
$file,
|
||||
preg_replace('/<!--' . $tag . '-->.*<!--\/' . $tag . '-->/s', '', $contents) ?: $contents
|
||||
);
|
||||
}
|
||||
|
||||
function setupPackageJsonForTheme(): void
|
||||
{
|
||||
removeNpmDeps([
|
||||
'purge',
|
||||
'dev',
|
||||
'dev:scripts',
|
||||
'build',
|
||||
'build:scripts',
|
||||
], 'scripts');
|
||||
|
||||
removeNpmDeps([
|
||||
'@awcodes/filament-plugin-purge',
|
||||
'esbuild',
|
||||
'npm-run-all',
|
||||
'prettier',
|
||||
'prettier-plugin-tailwindcss',
|
||||
], 'devDependencies');
|
||||
|
||||
replaceInFile(__DIR__ . '/package.json', [
|
||||
'dev:styles' => 'dev',
|
||||
'build:styles' => 'build',
|
||||
]);
|
||||
}
|
||||
|
||||
function safeUnlink(string $filename): void
|
||||
{
|
||||
if (file_exists($filename) && is_file($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
||||
function determineSeparator(string $path): string
|
||||
{
|
||||
return str_replace('/', DIRECTORY_SEPARATOR, $path);
|
||||
}
|
||||
|
||||
function replaceForWindows(): array
|
||||
{
|
||||
return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i \\vendor\\ | findstr /v /i ' . basename(__FILE__) . ' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton migration_table_name vendor_name vendor_slug author@domain.com"'));
|
||||
}
|
||||
|
||||
function replaceForAllOtherOSes(): array
|
||||
{
|
||||
return explode(PHP_EOL, run('find ./* ./.github/* -name "vendor" -type d -prune \
|
||||
-o -name "configure.php" -prune \
|
||||
-o -type f -print0 | xargs -0 grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|migration_table_name|vendor_name|vendor_slug|author@domain.com"'));
|
||||
}
|
||||
|
||||
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,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton\Database\Factories;
|
||||
namespace AlexanderGabriel\FilamentOauth2\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('migration_table_name_table', function (Blueprint $table) {
|
||||
Schema::create('filament_oauth2_table', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// add fields
|
||||
@ -2,11 +2,11 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/skeleton.css --postcss --watch",
|
||||
"dev:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/filament-oauth2.css --postcss --watch",
|
||||
"dev:scripts": "node bin/build.js --dev",
|
||||
"build:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/skeleton.css --postcss --minify && npm run purge",
|
||||
"build:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/filament-oauth2.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",
|
||||
"purge": "filament-purge -i resources/dist/filament-oauth2.css -o resources/dist/filament-oauth2.css -v 3.x",
|
||||
"dev": "npm-run-all --parallel dev:*",
|
||||
"build": "npm-run-all build:*"
|
||||
},
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
backupStaticProperties="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="VendorName Test Suite">
|
||||
<testsuite name="AlexanderGabriel Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
6
resources/lang/en/oauth2.php
Normal file
6
resources/lang/en/oauth2.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// translations for AlexanderGabriel/FilamentOauth2
|
||||
return [
|
||||
//
|
||||
];
|
||||
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
// translations for VendorName/Skeleton
|
||||
return [
|
||||
//
|
||||
];
|
||||
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton\Commands;
|
||||
namespace AlexanderGabriel\FilamentOauth2\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SkeletonCommand extends Command
|
||||
class FilamentOauth2Command extends Command
|
||||
{
|
||||
public $signature = 'skeleton';
|
||||
public $signature = 'filament-oauth2';
|
||||
|
||||
public $description = 'My command';
|
||||
|
||||
16
src/Facades/FilamentOauth2.php
Normal file
16
src/Facades/FilamentOauth2.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace AlexanderGabriel\FilamentOauth2\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* @see \AlexanderGabriel\FilamentOauth2\FilamentOauth2
|
||||
*/
|
||||
class FilamentOauth2 extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return \AlexanderGabriel\FilamentOauth2\FilamentOauth2::class;
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* @see \VendorName\Skeleton\Skeleton
|
||||
*/
|
||||
class Skeleton extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return \VendorName\Skeleton\Skeleton::class;
|
||||
}
|
||||
}
|
||||
5
src/FilamentOauth2.php
Normal file
5
src/FilamentOauth2.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace AlexanderGabriel\FilamentOauth2;
|
||||
|
||||
class FilamentOauth2 {}
|
||||
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
namespace AlexanderGabriel\FilamentOauth2;
|
||||
|
||||
use Filament\Contracts\Plugin;
|
||||
use Filament\Panel;
|
||||
|
||||
class SkeletonPlugin implements Plugin
|
||||
class FilamentOauth2Plugin implements Plugin
|
||||
{
|
||||
public function getId(): string
|
||||
{
|
||||
return 'skeleton';
|
||||
return 'filament-oauth2';
|
||||
}
|
||||
|
||||
public function register(Panel $panel): void
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
namespace AlexanderGabriel\FilamentOauth2;
|
||||
|
||||
use Filament\Support\Assets\AlpineComponent;
|
||||
use Filament\Support\Assets\Asset;
|
||||
@ -13,14 +13,14 @@ use Livewire\Features\SupportTesting\Testable;
|
||||
use Spatie\LaravelPackageTools\Commands\InstallCommand;
|
||||
use Spatie\LaravelPackageTools\Package;
|
||||
use Spatie\LaravelPackageTools\PackageServiceProvider;
|
||||
use VendorName\Skeleton\Commands\SkeletonCommand;
|
||||
use VendorName\Skeleton\Testing\TestsSkeleton;
|
||||
use AlexanderGabriel\FilamentOauth2\Commands\FilamentOauth2Command;
|
||||
use AlexanderGabriel\FilamentOauth2\Testing\TestsFilamentOauth2;
|
||||
|
||||
class SkeletonServiceProvider extends PackageServiceProvider
|
||||
class FilamentOauth2ServiceProvider extends PackageServiceProvider
|
||||
{
|
||||
public static string $name = 'skeleton';
|
||||
public static string $name = 'filament-oauth2';
|
||||
|
||||
public static string $viewNamespace = 'skeleton';
|
||||
public static string $viewNamespace = 'filament-oauth2';
|
||||
|
||||
public function configurePackage(Package $package): void
|
||||
{
|
||||
@ -36,7 +36,7 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
->publishConfigFile()
|
||||
->publishMigrations()
|
||||
->askToRunMigrations()
|
||||
->askToStarRepoOnGitHub(':vendor_slug/:package_slug');
|
||||
->askToStarRepoOnGitHub('alexandergabriel/filament-oauth2');
|
||||
});
|
||||
|
||||
$configFileName = $package->shortName();
|
||||
@ -80,18 +80,18 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
if (app()->runningInConsole()) {
|
||||
foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) {
|
||||
$this->publishes([
|
||||
$file->getRealPath() => base_path("stubs/skeleton/{$file->getFilename()}"),
|
||||
], 'skeleton-stubs');
|
||||
$file->getRealPath() => base_path("stubs/filament-oauth2/{$file->getFilename()}"),
|
||||
], 'filament-oauth2-stubs');
|
||||
}
|
||||
}
|
||||
|
||||
// Testing
|
||||
Testable::mixin(new TestsSkeleton);
|
||||
Testable::mixin(new TestsFilamentOauth2);
|
||||
}
|
||||
|
||||
protected function getAssetPackageName(): ?string
|
||||
{
|
||||
return ':vendor_slug/:package_slug';
|
||||
return 'alexandergabriel/filament-oauth2';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,9 +100,9 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
protected function getAssets(): array
|
||||
{
|
||||
return [
|
||||
// AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'),
|
||||
Css::make('skeleton-styles', __DIR__ . '/../resources/dist/skeleton.css'),
|
||||
Js::make('skeleton-scripts', __DIR__ . '/../resources/dist/skeleton.js'),
|
||||
// AlpineComponent::make('filament-oauth2', __DIR__ . '/../resources/dist/components/filament-oauth2.js'),
|
||||
Css::make('filament-oauth2-styles', __DIR__ . '/../resources/dist/filament-oauth2.css'),
|
||||
Js::make('filament-oauth2-scripts', __DIR__ . '/../resources/dist/filament-oauth2.js'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
protected function getCommands(): array
|
||||
{
|
||||
return [
|
||||
SkeletonCommand::class,
|
||||
FilamentOauth2Command::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class SkeletonServiceProvider extends PackageServiceProvider
|
||||
protected function getMigrations(): array
|
||||
{
|
||||
return [
|
||||
'create_skeleton_table',
|
||||
'create_filament-oauth2_table',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
|
||||
class Skeleton {}
|
||||
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton;
|
||||
|
||||
use Filament\Contracts\Plugin;
|
||||
use Filament\Panel;
|
||||
use Filament\Support\Assets\Theme;
|
||||
use Filament\Support\Color;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
|
||||
class Skeleton implements Plugin
|
||||
{
|
||||
public function getId(): string
|
||||
{
|
||||
return 'skeleton';
|
||||
}
|
||||
|
||||
public function register(Panel $panel): void
|
||||
{
|
||||
FilamentAsset::register([
|
||||
Theme::make('skeleton', __DIR__ . '/../resources/dist/skeleton.css'),
|
||||
]);
|
||||
|
||||
$panel
|
||||
->font('DM Sans')
|
||||
->primaryColor(Color::Amber)
|
||||
->secondaryColor(Color::Gray)
|
||||
->warningColor(Color::Amber)
|
||||
->dangerColor(Color::Rose)
|
||||
->successColor(Color::Green)
|
||||
->grayColor(Color::Gray)
|
||||
->theme('skeleton');
|
||||
}
|
||||
|
||||
public function boot(Panel $panel): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton\Testing;
|
||||
namespace AlexanderGabriel\FilamentOauth2\Testing;
|
||||
|
||||
use Livewire\Features\SupportTesting\Testable;
|
||||
|
||||
/**
|
||||
* @mixin Testable
|
||||
*/
|
||||
class TestsSkeleton
|
||||
class TestsFilamentOauth2
|
||||
{
|
||||
//
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
use VendorName\Skeleton\Tests\TestCase;
|
||||
use AlexanderGabriel\FilamentOauth2\Tests\TestCase;
|
||||
|
||||
uses(TestCase::class)->in(__DIR__);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace VendorName\Skeleton\Tests;
|
||||
namespace AlexanderGabriel\FilamentOauth2\Tests;
|
||||
|
||||
use BladeUI\Heroicons\BladeHeroiconsServiceProvider;
|
||||
use BladeUI\Icons\BladeIconsServiceProvider;
|
||||
@ -16,7 +16,7 @@ use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Livewire\LivewireServiceProvider;
|
||||
use Orchestra\Testbench\TestCase as Orchestra;
|
||||
use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider;
|
||||
use VendorName\Skeleton\SkeletonServiceProvider;
|
||||
use AlexanderGabriel\FilamentOauth2\FilamentOauth2ServiceProvider;
|
||||
|
||||
class TestCase extends Orchestra
|
||||
{
|
||||
@ -25,7 +25,7 @@ class TestCase extends Orchestra
|
||||
parent::setUp();
|
||||
|
||||
Factory::guessFactoryNamesUsing(
|
||||
fn (string $modelName) => 'VendorName\\Skeleton\\Database\\Factories\\' . class_basename($modelName) . 'Factory'
|
||||
fn (string $modelName) => 'AlexanderGabriel\\FilamentOauth2\\Database\\Factories\\' . class_basename($modelName) . 'Factory'
|
||||
);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class TestCase extends Orchestra
|
||||
SupportServiceProvider::class,
|
||||
TablesServiceProvider::class,
|
||||
WidgetsServiceProvider::class,
|
||||
SkeletonServiceProvider::class,
|
||||
FilamentOauth2ServiceProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class TestCase extends Orchestra
|
||||
config()->set('database.default', 'testing');
|
||||
|
||||
/*
|
||||
$migration = include __DIR__.'/../database/migrations/create_skeleton_table.php.stub';
|
||||
$migration = include __DIR__.'/../database/migrations/create_filament-oauth2_table.php.stub';
|
||||
$migration->up();
|
||||
*/
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user