diff --git a/.editorconfig b/.editorconfig index dd9a2b5..a7c44dd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,9 +2,9 @@ root = true [*] charset = utf-8 -end_of_line = lf indent_size = 4 indent_style = space +end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..b4ae1c4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 7546b77..bc5e177 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,18 +1,18 @@ name: Bug Report description: Report an Issue or Bug with the Package title: "[Bug]: " -labels: ["bug"] +labels: [ "bug" ] body: - type: markdown attributes: - value: | - We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + value: "| +We're sorry to hear you have a problem. Can you help us solve it by providing the following details." - type: textarea id: what-happened attributes: label: What happened? description: What did you expect to happen? - placeholder: I cannot currently do X thing because when I do, it breaks X thing. + placeholder: "I cannot currently do X thing because when I do, it breaks X thing." validations: required: true - type: input @@ -20,7 +20,8 @@ body: attributes: label: Package Version description: What version of our Package are you running? Please be as specific as possible - placeholder: 1.0.0 + placeholder: "12.0" + value: "12.0" validations: required: true - type: input @@ -28,7 +29,8 @@ body: attributes: label: PHP Version description: What version of PHP are you running? Please be as specific as possible - placeholder: 8.3.0 + placeholder: "8.4.0" + value: "8.4.0" validations: required: true - type: input @@ -36,7 +38,8 @@ body: attributes: label: Laravel Version description: What version of Laravel are you running? Please be as specific as possible - placeholder: 11.0.0 + placeholder: "12.0.0" + value: "12.0.0" validations: required: true - type: dropdown diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..dd923a2 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +If you discover any security related issues, please email info@codebar.ch instead of using the issue tracker. diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 2cb1d5e..2df1631 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -10,20 +10,20 @@ jobs: runs-on: ubuntu-latest if: ${{ github.actor == 'dependabot[bot]' }} steps: - + - name: Dependabot metadata id: metadata uses: dependabot/fetch-metadata@v2.3.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" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..0d4a013 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,20 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v4 + - name: 'Dependency Review' + uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 0edbd38..ef2fadf 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -1,12 +1,6 @@ name: Fix PHP code style issues -on: - push: - paths: - - '**.php' - -permissions: - contents: write +on: [push] jobs: php-code-styling: diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index ff2ab7b..b0cde6a 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,12 +16,9 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.4' coverage: none - - name: Apply Nova license - run: composer config http-basic.nova.laravel.com ${{ secrets.NOVA_USERNAME }} ${{ secrets.NOVA_LICENSE_KEY }} - - name: Install composer dependencies uses: ramsey/composer-install@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..afa28ff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: release + +on: + pull_request: + types: + - closed + branches: + - main +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Bump version and push tag + uses: anothrNick/github-tag-action@master + env: + GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} + WITH_V: true + RELEASE_BRANCHES: main + DEFAULT_BUMP: minor diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a8ad035..11f24f5 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -2,20 +2,21 @@ name: run-tests on: push: - branches: [main] + branches: [ main ] pull_request: - branches: [main] + branches: [ main ] jobs: test: runs-on: ${{ matrix.os }} strategy: fail-fast: true + max-parallel: 1 matrix: - os: [ubuntu-latest] - php: [ 8.2, 8.3 ] - laravel: [ 11.* ] - stability: [prefer-stable] + os: [ ubuntu-latest ] + php: [ 8.2, 8.3, 8.4 ] + laravel: [ 12.* ] + stability: [ prefer-lowest, prefer-stable ] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -43,8 +44,15 @@ jobs: composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - name: List Installed Dependencies - run: composer show -D + - name: Execute tests + run: cp phpunit.xml.dist phpunit.xml - name: Execute tests - run: vendor/bin/pest --ci + run: vendor/bin/pest + + - name: Store Log Artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: Store report artifacts + path: ./vendor/orchestra/testbench-core/laravel/storage/logs diff --git a/.gitignore b/.gitignore index 5cdf776..91b23b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ .idea +.phpunit.result.cache .phpunit.cache -build composer.lock coverage -docs phpunit.xml phpstan.neon testbench.yaml vendor node_modules -auth.json \ No newline at end of file +.phpactor.json +build diff --git a/README.md b/README.md index 6ed5c6f..1358575 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ [![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/laravel-flysystem-cloudinary-nova.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-flysystem-cloudinary-nova) +[![GitHub-Tests](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/run-tests.yml) +[![GitHub Code Style](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/fix-php-code-style-issues.yml) [![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/laravel-flysystem-cloudinary-nova.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-flysystem-cloudinary-nova) -[![run-tests](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/run-tests.yml) -[![PHPStan](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/phpstan.yml) -[![Fix PHP code style issues](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova/actions/workflows/fix-php-code-style-issues.yml) ## 🛠 Requirements @@ -15,10 +14,12 @@ - Cloudinary Account -| Package | PHP | Laravel | Flysystem | -|-----------|--------|---------------|-------------| -| >v2.0 | >8.3 | > Laravel 11 | > 3.0 | -| >v1.0 | >8.2 | > Laravel 10 | > 3.0 | +| Package | PHP | Laravel | Nova | Flysystem | +|-----------|-------------|-----------|--------|-------------| +| v12.0 | ^8.2 - ^8.4 | 12.x | ^5.2.6 | 3.25.1 | +| v11.0 | ^8.2 - ^8.3 | 11.x | ^4.3 | 3.0 | +| v2.0.0 | ^8.2 | 11.x | ^4.3 | 3.0 | +| v1.0.0 | ^8.2 | 10.x | ^4.3 | 3.0 | ## ⚙️ Installation diff --git a/composer.json b/composer.json index a4cafde..4bd0af5 100644 --- a/composer.json +++ b/composer.json @@ -1,79 +1,80 @@ { - "name": "codebar-ag/laravel-flysystem-cloudinary-nova", - "description": "This is my package laravel-flysystem-cloudinary-nova", - "keywords": [ - "codebar-ag", - "laravel", - "laravel-flysystem-cloudinary-nova" - ], - "homepage": "https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova", - "license": "MIT", - "authors": [ - { - "name": "Sebastian Fix", - "email": "sebastian.fix@codebar.ch", - "homepage": "https://www.codebar.ch", - "role": "Software Engineer" - } - ], - "require": { - "php": ">=8.2", - "spatie/laravel-package-tools": "^1.16", - "illuminate/contracts": "^11.0", - "codebar-ag/laravel-flysystem-cloudinary": "^11.0", - "laravel/nova": ">=4.3" - }, - "require-dev": { - "laravel/pint": "^1.13", - "nunomaduro/collision": "^8.1", - "larastan/larastan": "^2.9", - "orchestra/testbench": "^9.0", - "pestphp/pest": "^2.33", - "pestphp/pest-plugin-arch": "^2.7", - "pestphp/pest-plugin-laravel": "^2.2", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "spatie/laravel-ray": "^1.35" - }, - "repositories": [ - { - "type": "composer", - "url": "https://nova.laravel.com" - } - ], - "autoload": { - "psr-4": { - "CodebarAg\\FlysystemCloudinaryNova\\": "src/", - "CodebarAg\\FlysystemCloudinaryNova\\Database\\Factories\\": "database/factories/" - } - }, - "autoload-dev": { - "psr-4": { - "CodebarAg\\FlysystemCloudinaryNova\\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" - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "pestphp/pest-plugin": true, - "phpstan/extension-installer": true - } - }, - "extra": { - "laravel": { - "providers": [ - "CodebarAg\\FlysystemCloudinaryNova\\FlysystemCloudinaryNovaServiceProvider" - ] - } - }, - "minimum-stability": "stable", - "prefer-stable": true + "name": "codebar-ag/laravel-flysystem-cloudinary-nova", + "description": "This is my package laravel-flysystem-cloudinary-nova", + "keywords": [ + "codebar-ag", + "laravel", + "laravel-flysystem-cloudinary-nova" + ], + "homepage": "https://github.com/codebar-ag/laravel-flysystem-cloudinary-nova", + "license": "MIT", + "authors": [ + { + "name": "Sebastian Bürgin-Fix", + "email": "sebastian.buergin@buergin.ch", + "homepage": "https://www.codebar.ch", + "role": "Sofware-Engineer" + }, + { + "name": "Rhys Lees", + "role": "Software-Engineer" + } + ], + "require": { + "php": "8.2.*|8.3.*|8.4.*", + "illuminate/contracts": "^12.0", + "spatie/laravel-package-tools": "^1.19", + "codebar-ag/laravel-flysystem-cloudinary": "dev-feature-laravel-12", + "laravel/nova": "^5.2.6" + }, + "require-dev": { + "laravel/pint": "^1.21", + "larastan/larastan": "^v3.1", + "orchestra/testbench": "^10.0", + "pestphp/pest": "^3.7", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "spatie/laravel-ray": "^1.39" + }, + "repositories": [ + { + "type": "composer", + "url": "https://nova.laravel.com" + } + ], + "autoload": { + "psr-4": { + "CodebarAg\\FlysystemCloudinaryNova\\": "src/", + "CodebarAg\\FlysystemCloudinaryNova\\Database\\Factories\\": "database/factories/" + } + }, + "autoload-dev": { + "psr-4": { + "CodebarAg\\FlysystemCloudinaryNova\\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" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true + } + }, + "extra": { + "laravel": { + "providers": [ + "CodebarAg\\FlysystemCloudinaryNova\\FlysystemCloudinaryNovaServiceProvider" + ] + } + }, + "minimum-stability": "stable", + "prefer-stable": true } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e005ac7..0cc2d04 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,12 +2,11 @@ includes: - phpstan-baseline.neon parameters: - level: 4 + level: 5 paths: - src - config tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false - + noEnvCallsOutsideOfConfig: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da39c85..e36c338 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ @@ -16,7 +16,11 @@ + + + + diff --git a/src/CloudinaryImage.php b/src/CloudinaryImage.php index 0a712a5..bf075f8 100644 --- a/src/CloudinaryImage.php +++ b/src/CloudinaryImage.php @@ -20,6 +20,7 @@ public function __construct($name, $attribute = null, $disk = 'cloudinary', $sto $this->thumbnail(function () { return $this->value + // @phpstan-ignore-next-line ? Storage::disk('cloudinary')->url([ 'path' => $this->value, 'options' => [ @@ -32,6 +33,7 @@ public function __construct($name, $attribute = null, $disk = 'cloudinary', $sto : null; })->preview(function () { return $this->value + // @phpstan-ignore-next-line ? Storage::disk('cloudinary')->url([ 'path' => $this->value, 'options' => [