From ccebbc5a79b73b32f9213acc0d09943ded9b8088 Mon Sep 17 00:00:00 2001 From: Dennis Elsinga Date: Thu, 27 Jun 2024 09:38:52 +0200 Subject: [PATCH] Setup --- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 6 +- .github/SECURITY.md | 2 +- .github/dependabot.yml | 12 - .github/workflows/dependabot-auto-merge.yml | 33 -- .../workflows/fix-php-code-style-issues.yml | 27 -- .github/workflows/phpstan.yml | 26 -- .github/workflows/update-changelog.yml | 31 -- CHANGELOG.md | 2 +- LICENSE.md | 2 +- README.md | 32 +- bin/build.js | 2 +- composer.json | 44 +-- config/simple-alert.php | 6 + config/skeleton.php | 6 - configure.php | 370 ------------------ database/factories/ModelFactory.php | 2 +- ...tub => create_simple_alert_table.php.stub} | 2 +- package.json | 6 +- phpstan-baseline.neon | 0 phpstan.neon.dist | 14 - phpunit.xml.dist | 2 +- pint.json | 14 - resources/lang/en/simple-alert.php | 6 + resources/lang/en/skeleton.php | 6 - ...etonCommand.php => SimpleAlertCommand.php} | 6 +- src/Facades/SimpleAlert.php | 16 + src/Facades/Skeleton.php | 16 - src/SimpleAlert.php | 5 + ...eletonPlugin.php => SimpleAlertPlugin.php} | 6 +- ...der.php => SimpleAlertServiceProvider.php} | 32 +- src/Skeleton.php | 5 - src/SkeletonTheme.php | 39 -- ...TestsSkeleton.php => TestsSimpleAlert.php} | 4 +- tests/Pest.php | 2 +- tests/TestCase.php | 10 +- 36 files changed, 106 insertions(+), 690 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/dependabot-auto-merge.yml delete mode 100644 .github/workflows/fix-php-code-style-issues.yml delete mode 100644 .github/workflows/phpstan.yml delete mode 100644 .github/workflows/update-changelog.yml create mode 100644 config/simple-alert.php delete mode 100644 config/skeleton.php delete mode 100644 configure.php rename database/migrations/{create_skeleton_table.php.stub => create_simple_alert_table.php.stub} (78%) delete mode 100644 phpstan-baseline.neon delete mode 100644 phpstan.neon.dist delete mode 100644 pint.json create mode 100644 resources/lang/en/simple-alert.php delete mode 100644 resources/lang/en/skeleton.php rename src/Commands/{SkeletonCommand.php => SimpleAlertCommand.php} (59%) create mode 100644 src/Facades/SimpleAlert.php delete mode 100644 src/Facades/Skeleton.php create mode 100644 src/SimpleAlert.php rename src/{SkeletonPlugin.php => SimpleAlertPlugin.php} (81%) rename src/{SkeletonServiceProvider.php => SimpleAlertServiceProvider.php} (73%) delete mode 100644 src/Skeleton.php delete mode 100644 src/SkeletonTheme.php rename src/Testing/{TestsSkeleton.php => TestsSimpleAlert.php} (57%) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c68765b..4ccb3f4 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: :vendor_name +github: CodeWithDennis diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 96701be..4273766 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -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/CodeWithDennis/filament-simple-alert/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/CodeWithDennis/filament-simple-alert/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/CodeWithDennis/filament-simple-alert/security/policy about: Learn how to notify us for sensitive bugs diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 12ab7c2..14a8063 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -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 personal.elsinga@gmail.com instead of using the issue tracker. diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 30c8a49..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - labels: - - "dependencies" \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml deleted file mode 100644 index d266418..0000000 --- a/.github/workflows/dependabot-auto-merge.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: "Dependabot Auto-Merge" - -on: pull_request_target - -permissions: - pull-requests: write - contents: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} - steps: - - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v1.6.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Auto-merge Dependabot PRs for semver-minor updates - if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - - name: Auto-merge Dependabot PRs for semver-patch updates - if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml deleted file mode 100644 index 756a961..0000000 --- a/.github/workflows/fix-php-code-style-issues.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: "Fix PHP Code Styling" - -on: - push: - paths: - - '**.php' - -permissions: - contents: write - -jobs: - php-code-styling: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - - - name: Fix PHP code style issues - uses: aglipanci/laravel-pint-action@2.4 - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: Fix styling diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index 3855a08..0000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: PHPStan - -on: - push: - paths: - - '**.php' - - 'phpstan.neon.dist' - -jobs: - phpstan: - name: phpstan - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - coverage: none - - - name: Install composer dependencies - uses: ramsey/composer-install@v3 - - - name: Run PHPStan - run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml deleted file mode 100644 index ec40921..0000000 --- a/.github/workflows/update-changelog.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "Update Changelog" - -on: - release: - types: [released] - -permissions: - contents: write - -jobs: - update: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - 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@v5 - with: - branch: main - commit_message: Update CHANGELOG - file_pattern: CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 767365d..9d8706e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to `:package_name` will be documented in this file. +All notable changes to `filament-simple-alert` will be documented in this file. ## 1.0.0 - 202X-XX-XX diff --git a/LICENSE.md b/LICENSE.md index 58c9ad4..5df7258 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) :vendor_name +Copyright (c) CodeWithDennis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 98f321d..1383bc7 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,11 @@ -# :package_description +# A plugin for adding straightforward alerts to your filament pages -[![Latest Version on Packagist](https://img.shields.io/packagist/v/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug) -[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3Arun-tests+branch%3Amain) -[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/codewithdennis/filament-simple-alert.svg?style=flat-square)](https://packagist.org/packages/codewithdennis/filament-simple-alert) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/codewithdennis/filament-simple-alert/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/codewithdennis/filament-simple-alert/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/codewithdennis/filament-simple-alert/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/codewithdennis/filament-simple-alert/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/codewithdennis/filament-simple-alert.svg?style=flat-square)](https://packagist.org/packages/codewithdennis/filament-simple-alert) - ---- -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! ---- - 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 codewithdennis/filament-simple-alert ``` You can publish and run the migrations with: ```bash -php artisan vendor:publish --tag=":package_slug-migrations" +php artisan vendor:publish --tag="filament-simple-alert-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-simple-alert-config" ``` Optionally, you can publish the views using ```bash -php artisan vendor:publish --tag=":package_slug-views" +php artisan vendor:publish --tag="filament-simple-alert-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!'); +$simpleAlert = new CodeWithDennis\SimpleAlert(); +echo $simpleAlert->echoPhrase('Hello, CodeWithDennis!'); ``` ## 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) +- [CodeWithDennis](https://github.com/CodeWithDennis) - [All Contributors](../../contributors) ## License diff --git a/bin/build.js b/bin/build.js index 913baf4..1c4b446 100644 --- a/bin/build.js +++ b/bin/build.js @@ -46,5 +46,5 @@ const defaultOptions = { compile({ ...defaultOptions, entryPoints: ['./resources/js/index.js'], - outfile: './resources/dist/skeleton.js', + outfile: './resources/dist/filament-simple-alert.js', }) diff --git a/composer.json b/composer.json index bb6be65..c407831 100644 --- a/composer.json +++ b/composer.json @@ -1,61 +1,51 @@ { - "name": ":vendor_slug/:package_slug", - "description": ":package_description", + "name": "codewithdennis/filament-simple-alert", + "description": "A plugin for adding straightforward alerts to your filament pages", "keywords": [ - ":vendor_name", + "CodeWithDennis", "laravel", - ":package_slug" + "filament-simple-alert" ], - "homepage": "https://github.com/:vendor_slug/:package_slug", + "homepage": "https://github.com/codewithdennis/filament-simple-alert", "support": { - "issues": "https://github.com/:vendor_slug/:package_slug/issues", - "source": "https://github.com/:vendor_slug/:package_slug" + "issues": "https://github.com/codewithdennis/filament-simple-alert/issues", + "source": "https://github.com/codewithdennis/filament-simple-alert" }, "license": "MIT", "authors": [ { - "name": ":author_name", - "email": "author@domain.com", + "name": "CodeWithDennis", + "email": "personal.elsinga@gmail.com", "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": { - "laravel/pint": "^1.0", "nunomaduro/collision": "^7.9", - "nunomaduro/larastan": "^2.0.1", "orchestra/testbench": "^8.0", "pestphp/pest": "^2.1", "pestphp/pest-plugin-arch": "^2.0", - "pestphp/pest-plugin-laravel": "^2.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "spatie/laravel-ray": "^1.26" + "pestphp/pest-plugin-laravel": "^2.0" }, "autoload": { "psr-4": { - "VendorName\\Skeleton\\": "src/", - "VendorName\\Skeleton\\Database\\Factories\\": "database/factories/" + "CodeWithDennis\\SimpleAlert\\": "src/", + "CodeWithDennis\\SimpleAlert\\Database\\Factories\\": "database/factories/" } }, "autoload-dev": { "psr-4": { - "VendorName\\Skeleton\\Tests\\": "tests/" + "CodeWithDennis\\SimpleAlert\\Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", - "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", - "test-coverage": "vendor/bin/pest --coverage", - "format": "vendor/bin/pint" + "test-coverage": "vendor/bin/pest --coverage" }, "config": { "sort-packages": true, @@ -67,13 +57,13 @@ "extra": { "laravel": { "providers": [ - "VendorName\\Skeleton\\SkeletonServiceProvider" + "CodeWithDennis\\SimpleAlert\\SimpleAlertServiceProvider" ], "aliases": { - "Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton" + "SimpleAlert": "CodeWithDennis\\SimpleAlert\\Facades\\SimpleAlert" } } }, "minimum-stability": "dev", "prefer-stable": true -} +} \ No newline at end of file diff --git a/config/simple-alert.php b/config/simple-alert.php new file mode 100644 index 0000000..fd885b2 --- /dev/null +++ b/config/simple-alert.php @@ -0,0 +1,6 @@ +" : '') . "\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('/.*/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); - } -} diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index c51604f..66aabdc 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -1,6 +1,6 @@ id(); // add fields diff --git a/package.json b/package.json index afec3c0..adbdb7b 100644 --- a/package.json +++ b/package.json @@ -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-simple-alert.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-simple-alert.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-simple-alert.css -o resources/dist/filament-simple-alert.css -v 3.x", "dev": "npm-run-all --parallel dev:*", "build": "npm-run-all build:*" }, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index e69de29..0000000 diff --git a/phpstan.neon.dist b/phpstan.neon.dist deleted file mode 100644 index a91953b..0000000 --- a/phpstan.neon.dist +++ /dev/null @@ -1,14 +0,0 @@ -includes: - - phpstan-baseline.neon - -parameters: - level: 4 - paths: - - src - - config - - database - tmpDir: build/phpstan - checkOctaneCompatibility: true - checkModelProperties: true - checkMissingIterableValueType: false - diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e953c0e..11a0340 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,7 @@ backupStaticProperties="false" > - + tests diff --git a/pint.json b/pint.json deleted file mode 100644 index c6ddb49..0000000 --- a/pint.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "preset": "laravel", - "rules": { - "blank_line_before_statement": true, - "concat_space": { - "spacing": "one" - }, - "method_argument_space": true, - "single_trait_insert_per_statement": true, - "types_spaces": { - "space": "single" - } - } -} diff --git a/resources/lang/en/simple-alert.php b/resources/lang/en/simple-alert.php new file mode 100644 index 0000000..986bb50 --- /dev/null +++ b/resources/lang/en/simple-alert.php @@ -0,0 +1,6 @@ +publishConfigFile() ->publishMigrations() ->askToRunMigrations() - ->askToStarRepoOnGitHub(':vendor_slug/:package_slug'); + ->askToStarRepoOnGitHub('codewithdennis/filament-simple-alert'); }); $configFileName = $package->shortName(); @@ -80,18 +80,18 @@ public function packageBooted(): void 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-simple-alert/{$file->getFilename()}"), + ], 'filament-simple-alert-stubs'); } } // Testing - Testable::mixin(new TestsSkeleton()); + Testable::mixin(new TestsSimpleAlert()); } protected function getAssetPackageName(): ?string { - return ':vendor_slug/:package_slug'; + return 'codewithdennis/filament-simple-alert'; } /** @@ -100,9 +100,9 @@ protected function getAssetPackageName(): ?string 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-simple-alert', __DIR__ . '/../resources/dist/components/filament-simple-alert.js'), + Css::make('filament-simple-alert-styles', __DIR__ . '/../resources/dist/filament-simple-alert.css'), + Js::make('filament-simple-alert-scripts', __DIR__ . '/../resources/dist/filament-simple-alert.js'), ]; } @@ -112,7 +112,7 @@ protected function getAssets(): array protected function getCommands(): array { return [ - SkeletonCommand::class, + SimpleAlertCommand::class, ]; } @@ -146,7 +146,7 @@ protected function getScriptData(): array protected function getMigrations(): array { return [ - 'create_skeleton_table', + 'create_filament-simple-alert_table', ]; } } diff --git a/src/Skeleton.php b/src/Skeleton.php deleted file mode 100644 index 34c7194..0000000 --- a/src/Skeleton.php +++ /dev/null @@ -1,5 +0,0 @@ -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 - { - // - } -} diff --git a/src/Testing/TestsSkeleton.php b/src/Testing/TestsSimpleAlert.php similarity index 57% rename from src/Testing/TestsSkeleton.php rename to src/Testing/TestsSimpleAlert.php index 0e33b51..d53b915 100644 --- a/src/Testing/TestsSkeleton.php +++ b/src/Testing/TestsSimpleAlert.php @@ -1,13 +1,13 @@ in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php index 14a77a0..7835ab3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,6 +1,6 @@ 'VendorName\\Skeleton\\Database\\Factories\\' . class_basename($modelName) . 'Factory' + fn (string $modelName) => 'CodeWithDennis\\SimpleAlert\\Database\\Factories\\' . class_basename($modelName) . 'Factory' ); } @@ -44,7 +44,7 @@ protected function getPackageProviders($app) SupportServiceProvider::class, TablesServiceProvider::class, WidgetsServiceProvider::class, - SkeletonServiceProvider::class, + SimpleAlertServiceProvider::class, ]; } @@ -53,7 +53,7 @@ public function getEnvironmentSetUp($app) config()->set('database.default', 'testing'); /* - $migration = include __DIR__.'/../database/migrations/create_skeleton_table.php.stub'; + $migration = include __DIR__.'/../database/migrations/create_filament-simple-alert_table.php.stub'; $migration->up(); */ }