diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..9e37cb0 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,12 @@ +name: FoF Social Profile PHP + +on: [workflow_dispatch, push, pull_request] + +jobs: + run: + uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main + with: + enable_backend_testing: false + enable_phpstan: true + + backend_directory: . diff --git a/.github/workflows/build.yml b/.github/workflows/frontend.yml similarity index 87% rename from .github/workflows/build.yml rename to .github/workflows/frontend.yml index ca3526b..ae2f474 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/frontend.yml @@ -1,4 +1,4 @@ -name: Javascript +name: FoF Social Profile JS on: [workflow_dispatch, push, pull_request] @@ -8,11 +8,12 @@ jobs: with: enable_bundlewatch: false enable_prettier: true - enable_typescript: false + enable_typescript: true frontend_directory: ./js backend_directory: . js_package_manager: npm main_git_branch: master + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/composer.json b/composer.json index c8165cd..1f1d971 100644 --- a/composer.json +++ b/composer.json @@ -1,53 +1,68 @@ { - "name": "fof/socialprofile", - "description": "Add custom social media pages to your user profile", - "keywords": [ - "flarum" - ], - "type": "flarum-extension", - "license": "MIT", - "support": { - "issues": "https://github.com/FriendsOfFlarum/socialprofile/issues", - "source": "https://github.com/FriendsOfFlarum/socialprofile", - "forum": "https://discuss.flarum.org/d/18775" - }, - "homepage": "https://friendsofflarum.org", - "funding": [ - { - "type": "website", - "url": "https://opencollective.com/fof/donate" - } - ], - "require": { - "flarum/core": "^1.3.1" - }, - "replace": { - "davis/flarum-ext-socialprofile": "*" - }, - "authors": [ - { - "name": "David Sevilla Martín", - "email": "david.s@redevs.org", - "role": "Developer" - } - ], - "autoload": { - "psr-4": { - "FoF\\SocialProfile\\": "src/" - } - }, - "extra": { - "flarum-extension": { - "title": "FoF Social Profile", - "category": "feature", - "icon": { - "name": "fas fa-globe", - "backgroundColor": "#e74c3c", - "color": "#ffff" - } + "name": "fof/socialprofile", + "description": "Add custom social media pages to your user profile", + "keywords": [ + "flarum" + ], + "type": "flarum-extension", + "license": "MIT", + "support": { + "issues": "https://github.com/FriendsOfFlarum/socialprofile/issues", + "source": "https://github.com/FriendsOfFlarum/socialprofile", + "forum": "https://discuss.flarum.org/d/18775" + }, + "homepage": "https://friendsofflarum.org", + "funding": [ + { + "type": "website", + "url": "https://opencollective.com/fof/donate" + } + ], + "require": { + "flarum/core": "^1.3.1" + }, + "replace": { + "davis/flarum-ext-socialprofile": "*" + }, + "authors": [ + { + "name": "David Sevilla Martín", + "email": "david.s@redevs.org", + "role": "Developer" + } + ], + "autoload": { + "psr-4": { + "FoF\\SocialProfile\\": "src/" + } + }, + "extra": { + "flarum-extension": { + "title": "FoF Social Profile", + "category": "feature", + "icon": { + "name": "fas fa-globe", + "backgroundColor": "#e74c3c", + "color": "#ffff" + } + }, + "flagrow": { + "discuss": "https://discuss.flarum.org/d/18775" + }, + "flarum-cli": { + "modules": { + "githubActions": true + } + } + }, + "require-dev": { + "flarum/phpstan": "*" + }, + "scripts": { + "analyse:phpstan": "phpstan analyse", + "clear-cache:phpstan": "phpstan clear-result-cache" }, - "flagrow": { - "discuss": "https://discuss.flarum.org/d/18775" + "scripts-descriptions": { + "analyse:phpstan": "Run static analysis" } - } } diff --git a/extend.php b/extend.php index b1779ff..5eeeb83 100644 --- a/extend.php +++ b/extend.php @@ -25,6 +25,9 @@ (new Extend\Frontend('admin')) ->js(__DIR__.'/js/dist/admin.js'), + (new Extend\Model(User::class)) + ->cast('social_buttons', 'string'), + (new Extend\Settings()) ->serializeToForum('fof-socialprofile.allow_external_favicons', 'fof-socialprofile.allow_external_favicons', 'boolval', true), diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..03cf261 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,13 @@ +includes: + - vendor/flarum/phpstan/extension.neon + +parameters: + # The level will be increased in Flarum 2.0 + level: 5 + paths: + - extend.php + - src + excludePaths: + - *.blade.php + checkMissingIterableValueType: false + databaseMigrationsPath: ['migrations'] diff --git a/src/Listeners/AddSocialButtonsToDatabase.php b/src/Listeners/AddSocialButtonsToDatabase.php index df825cb..5e61375 100644 --- a/src/Listeners/AddSocialButtonsToDatabase.php +++ b/src/Listeners/AddSocialButtonsToDatabase.php @@ -11,7 +11,9 @@ namespace FoF\SocialProfile\Listeners; +use Flarum\Foundation\ValidationException; use Flarum\User\Event\Saving; +use Flarum\User\Exception\PermissionDeniedException; use FoF\SocialProfile\Events\UserButtonsWereChanged; use FoF\SocialProfile\Validators\ProfileValidator; use Illuminate\Support\Arr;