Skip to content

Commit

Permalink
🚀 v5
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Meilick <[email protected]>
  • Loading branch information
bnomei committed Dec 1, 2024
1 parent 2777649 commit b5dc276
Show file tree
Hide file tree
Showing 20 changed files with 835 additions and 1,085 deletions.
Empty file modified .gitattributes
100755 → 100644
Empty file.
15 changes: 12 additions & 3 deletions .github/workflows/pest-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: Pest Tests

on: [ 'push', 'pull_request' ]
on:
workflow_dispatch:
push:
paths:
- "**.php"
- "composer.lock"
pull_request:
paths:
- "**.php"
- "composer.lock"

jobs:
test:
Expand All @@ -24,12 +33,12 @@ jobs:
key: composer-${{ hashFiles('composer.lock') }}

- name: Install
run: composer install --no-interaction --prefer-dist --optimize-autoloader
run: composer kirby

- name: Test & publish code coverage
uses: paambaati/[email protected]
with:
coverageCommand: composer coverage
coverageCommand: vendor/bin/pest --ci
coverageLocations: ${{github.workspace}}/tests/clover.xml:clover
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ jobs:
key: composer-${{ hashFiles('composer.lock') }}

- name: Install
run: |
composer install --no-interaction --prefer-dist --optimize-autoloader
run: composer kirby

- name: Run PHPStan
run: |
php tests/patch.php
./vendor/bin/phpstan --error-format=github
run: vendor/bin/phpstan --error-format=github
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Kirby Blueprints

![Release](https://flat.badgen.net/packagist/v/bnomei/kirby-blueprints?color=ae81ff)
![Downloads](https://flat.badgen.net/packagist/dt/bnomei/kirby-blueprints?color=272822)
[![Coverage](https://flat.badgen.net/codeclimate/coverage/bnomei/kirby-blueprints)](https://codeclimate.com/github/bnomei/kirby-blueprints)
[![Maintainability](https://flat.badgen.net/codeclimate/maintainability/bnomei/kirby-blueprints)](https://codeclimate.com/github/bnomei/kirby-blueprints)
[![Discord](https://flat.badgen.net/badge/discord/bnomei?color=7289da)](https://discordapp.com/users/bnomei)
[![Kirby 5](https://flat.badgen.net/badge/Kirby/5?color=ECC748)](https://getkirby.com)
![PHP 8.2](https://flat.badgen.net/badge/PHP/8.2?color=4E5B93&icon=php&label)
![Release](https://flat.badgen.net/packagist/v/bnomei/kirby-blueprints?color=ae81ff&icon=github&label)
![Downloads](https://flat.badgen.net/packagist/dt/bnomei/kirby-blueprints?color=272822&icon=github&label)
[![Coverage](https://flat.badgen.net/codeclimate/coverage/bnomei/kirby-blueprints?icon=codeclimate&label)](https://codeclimate.com/github/bnomei/kirby-blueprints)
[![Maintainability](https://flat.badgen.net/codeclimate/maintainability/bnomei/kirby-blueprints?icon=codeclimate&label)](https://codeclimate.com/github/bnomei/kirby-blueprints/issues)
[![Discord](https://flat.badgen.net/badge/discord/bnomei?color=7289da&icon=discord&label)](https://discordapp.com/users/bnomei)
[![Buymecoffee](https://flat.badgen.net/badge/icon/donate?icon=buymeacoffee&color=FF813F&label)](https://www.buymeacoffee.com/bnomei)

Kirby Ink - PHP Class-based Blueprints for Kirby CMS for better type safety and code completion.

Expand Down Expand Up @@ -151,7 +154,8 @@ return fn () => Field::make(FieldTypes::INFO)
->toArray();
```

> NOTE: For Models you can do that with the `defer` option. See further down.
> [!NOTE
> For Models you can do that with the `defer` option. See further down.

### Available Make-Helpers

Expand Down Expand Up @@ -556,6 +560,7 @@ If caching is enabled it will only compile the blueprint once and then use the c
]
```

> [!NOTE]
> The default can be set in the config.php of your plugin with the `bnomei.blueprints.expire` option.

Expand Down Expand Up @@ -591,6 +596,7 @@ class ExamplePage extends \Kirby\Cms\Page {
}
```

> [!NOTE]
> The cache will use the duration as defined in the `bnomei.blueprints.expire` option in the config.php of your plugin.
## Disclaimer
Expand Down
2 changes: 0 additions & 2 deletions classes/Blueprints/Attributes/Mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class Mode extends GenericAttribute
{
/**
* With the mode option you control which elements of the color field are available. Possible values: picker, input, options.
*
* @param string $mode
*/
public function __construct(
public string $mode
Expand Down
6 changes: 3 additions & 3 deletions classes/Blueprints/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function toArray(): array
// some might not be cacheable like when they are class based and have dynamic fields
// only set here now if they will not be written on __destruct by trait
// the cache could be null which means it will use the default value
if ($this->cache !== false && $this->cache !== 0 && ! method_exists($this->modelClass, 'blueprintCacheKey')) {
if ($this->cache !== false && $this->cache !== 0 && ! method_exists($this->modelClass, 'blueprintCacheKey')) { // @phpstan-ignore-line
BlueprintCache::set($key, $blueprint);
}

Expand Down Expand Up @@ -248,9 +248,9 @@ public static function arraySetKeysFromColumns(array $data): array
if (is_string($item)) {
$updated[$item] = true; // resolve attribute based definition
} elseif (is_array($item) && isset($item['id'])) {
$updated[Str::camel($item['id'])] = $item;
$updated[Str::camel(strval($item['id']))] = $item;
} elseif (is_array($item) && isset($item['label'])) {
$updated[Str::camel($item['label'])] = $item;
$updated[Str::camel(strval($item['label']))] = $item;
} else {
$json_encode = json_encode($item);
if ($json_encode === false) {
Expand Down
8 changes: 6 additions & 2 deletions classes/Blueprints/BlueprintCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ public static function rememberCacheDir(): void
return;
}

/** @var FileCache $cache */
$cache = kirby()->cache('bnomei.blueprints');
$dir = $cache->root();
if ($cache instanceof FileCache) {
$dir = $cache->root();
} else {
$dir = kirby()->roots()->cache();
}

if (! Dir::exists($dir)) {
Dir::make($dir);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/Blueprints/Schema/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function make(
array $sections = [],
array $fields = [],
): self {
return new self(...func_get_args()); // @phpstan-ignore-line
return new self(...func_get_args());
}

public function status(
Expand Down
2 changes: 2 additions & 0 deletions classes/Ink.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class Ink
{
const ALPHA = 'alpha';

const ACCEPT = 'accept';

const AFTER = 'after';
Expand Down Expand Up @@ -104,6 +105,7 @@ class Ink
const MAXLENGTH = 'maxlength';

const MIN = 'min';

const MODE = 'mode';

const MULTIPLE = 'multiple';
Expand Down
24 changes: 10 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,19 @@
"getkirby/composer-installer": "^1.2"
},
"require-dev": {
"bnomei/autoloader-for-kirby": "^4.2",
"getkirby/cms": "^5.0.0-alpha.3",
"bnomei/autoloader-for-kirby": "^5.0",
"getkirby/cms": "^5.0.0-alpha.4",
"larastan/larastan": "^v3.0.0",
"laravel/pint": "^1.11",
"pestphp/pest": "^2.24",
"pestphp/pest-plugin-drift": "^2.5",
"pestphp/pest-plugin-type-coverage": "^2.4",
"spatie/ray": "^1.37"
"laravel/pint": "^1.13",
"pestphp/pest": "^v3.5.1",
"spatie/ray": "^1.39"
},
"scripts": {
"analyze": "./vendor/bin/phpstan",
"stan": "./vendor/bin/phpstan",
"fix": "./vendor/bin/pint",
"test": "./vendor/bin/pest",
"coverage": [
"php tests/patch.php",
"./vendor/bin/pest --coverage"
],
"test": "./vendor/bin/pest --profile",
"dist": [
"composer fix",
"composer install --no-dev --optimize-autoloader",
"git rm -rf --cached .; git add .;"
],
Expand All @@ -77,7 +72,8 @@
"composer update",
"composer install --working-dir=tests/kirby --no-dev --optimize-autoloader",
"composer update --working-dir=tests/kirby",
"php tests/patch.php"
"sed -i.bak 's/function dump(/function xdump(/g' tests/kirby/config/helpers.php",
"sed -i.bak 's/function e(/function xe(/g' tests/kirby/config/helpers.php"
]
},
"extra": {
Expand Down
Loading

0 comments on commit b5dc276

Please sign in to comment.