1
0
mirror of https://github.com/themsaid/ibis.git synced 2025-01-16 21:18:35 +01:00

Merge pull request #58 from roberto-butti/feature/upgrade-php83

Support for PHP 8.3
This commit is contained in:
Mohamed Said 2024-12-06 20:02:56 +04:00 committed by GitHub
commit 6f6653f427
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 826 additions and 1594 deletions

View File

@ -4,24 +4,28 @@ on: [push, pull_request]
jobs:
php-cs-fixer:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.2' ]
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
steps:
# This is required as this package does not support PHP 8 (yet)
- name: Setup PHP 7.4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -32,3 +36,40 @@ jobs:
- name: Execute PHP CS Fixer review
run: composer run csfix-review
check-ibis:
runs-on: ubuntu-latest
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.3', '8.2','8.1', '8.0' ]
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
steps:
# This is required as this package does not support PHP 8 (yet)
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer Cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
run: "composer update"
- name: test Ibis execution
run: |
mkdir export
./ibis init
./ibis build

6
.gitignore vendored
View File

@ -3,3 +3,9 @@ vendor/
.php_cs.cache
.DS_Store
/.idea
# Files/Dirs created by ibis init
assets/
content/
export/
ibis.php

49
.php_cs
View File

@ -1,49 +0,0 @@
<?php
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'method_separation' => true,
'no_multiline_whitespace_before_semicolons' => true,
'single_quote' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
],
'blank_line_after_opening_tag' => true,
'braces' => [
'allow_single_line_closure' => true,
],
'concat_space' => ['spacing' => 'none'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'include' => true,
'lowercase_cast' => true,
'no_extra_consecutive_blank_lines' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
],
'ordered_imports' => [
'sort_algorithm' => 'length'
],
'no_multiline_whitespace_around_double_arrow' => true,
'no_spaces_around_offset' => true,
'no_unused_imports' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'single_blank_line_before_namespace' => true,
'ternary_operator_spaces' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'not_operator_with_successor_space' => true,
])
->setLineEnding("\n");

View File

@ -19,15 +19,15 @@
"ibis"
],
"require": {
"illuminate/filesystem": "^7.0|^8.0",
"illuminate/support": "^7.0|^8.0",
"symfony/console": "^4.2|^5.0",
"illuminate/filesystem": "^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "^7.0|^8.0|^9.0|^10.0",
"mpdf/mpdf": "^8.1",
"spatie/commonmark-highlighter": "^2.1"
"spatie/commonmark-highlighter": "^2.1|^3.0",
"symfony/console": "^4.2|^5.0|^6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"symfony/var-dumper": "^5.0"
"laravel/pint": "^1.2",
"symfony/var-dumper": "^5.0|^6.0"
},
"autoload": {
"psr-4": {
@ -40,15 +40,15 @@
},
"scripts": {
"csfix": [
"php-cs-fixer fix src stubs --config=.php_cs"
"pint"
],
"csfix-review": [
"php-cs-fixer fix src stubs --config=.php_cs --dry-run -v"
"pint --test"
]
},
"scripts-descriptions": {
"csfix": "Runs PHP CS Fixer to fix project files.",
"csfix-review": "Runs PHP CS Fixer to show the details of which files are out of code standard."
"csfix": "Runs Pint to fix project files.",
"csfix-review": "Runs Pint to show the details of which files are out of code standard."
},
"minimum-stability": "dev",
"prefer-stable": true

2261
composer.lock generated

File diff suppressed because it is too large Load Diff

3
pint.json Normal file
View File

@ -0,0 +1,3 @@
{
"preset": "psr12"
}

View File

@ -7,7 +7,8 @@ use Mpdf\Mpdf;
use SplFileInfo;
use Mpdf\Config\FontVariables;
use Mpdf\Config\ConfigVariables;
use League\CommonMark\Environment;
use League\CommonMark\Environment\Environment;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Command\Command;
use League\CommonMark\Block\Element\FencedCode;
@ -64,8 +65,13 @@ class BuildCommand extends Command
$this->themeName = $input->getArgument('theme');
$currentPath = getcwd();
$config = require $currentPath.'/ibis.php';
$configIbisFile = $currentPath . '/ibis.php';
if (!$this->disk->isFile($configIbisFile)) {
$this->output->writeln('<error>Error, check if ' . $configIbisFile . ' exists.</error>');
exit - 1;
}
$config = require $configIbisFile;
$this->ensureExportDirectoryExists(
$currentPath = getcwd()
);
@ -113,7 +119,7 @@ class BuildCommand extends Command
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new TableExtension());
$environment->addBlockRenderer(FencedCode::class, new FencedCodeRenderer([
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer([
'html', 'php', 'js', 'bash', 'json'
]));
@ -207,8 +213,11 @@ class BuildCommand extends Command
$pdf->h2bookmarks = $tocLevels;
$pdf->SetMargins(400, 100, 12);
if ($this->disk->isFile($currentPath.'/assets/cover.jpg')) {
$coverImage="cover.jpg";
if (key_exists("image", $config['cover'])) {
$coverImage = $config['cover']['image'];
}
if ($this->disk->isFile($currentPath.'/assets/' . $coverImage)) {
$this->output->writeln('<fg=yellow>==></> Adding Book Cover ...');
$coverPosition = $config['cover']['position'] ?? 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;';
@ -217,7 +226,7 @@ class BuildCommand extends Command
$pdf->WriteHTML(
<<<HTML
<div style="{$coverPosition}">
<img src="assets/cover.jpg" style="{$coverDimensions}"/>
<img src="assets/{$coverImage}" style="{$coverDimensions}"/>
</div>
HTML
);
@ -232,7 +241,7 @@ HTML
$pdf->AddPage();
} else {
$this->output->writeln('<fg=red>==></> No assets/cover.jpg File Found. Skipping ...');
$this->output->writeln('<fg=red>==></> No assets/' . $coverImage . ' File Found. Skipping ...');
}
$pdf->SetHTMLFooter('<div id="footer" style="text-align: center">{PAGENO}</div>');

View File

@ -44,6 +44,7 @@ return [
'cover' => [
'position' => 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;',
'dimensions' => 'width: 210mm; height: 297mm; margin: 0;',
'image' => 'cover.jpg',
],
/**