From 7b13c3fbb62ba0f308cef670ed24a859cd0b98a2 Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:25:54 +0100 Subject: [PATCH 1/8] Remove unnecessary 'which' command from Windows workflow --- .github/workflows/run-windows.yml | 2 -- tests/PdfTest.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/run-windows.yml b/.github/workflows/run-windows.yml index 6c7c629..f0fbf55 100644 --- a/.github/workflows/run-windows.yml +++ b/.github/workflows/run-windows.yml @@ -14,10 +14,8 @@ jobs: scoop update scoop install 7zip scoop install imagemagick ghostscript ffmpeg - scoop install which scoop checkup [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - which 7z shell: powershell - name: Checkout code diff --git a/tests/PdfTest.php b/tests/PdfTest.php index 729b2e6..25adb36 100644 --- a/tests/PdfTest.php +++ b/tests/PdfTest.php @@ -26,7 +26,7 @@ expect($content)->toBeString(); expect($file)->toBeReadableFile(); -}); +})->skip(PHP_OS_FAMILY === 'Windows', 'Skip on Windows'); it('can extract some files', function () { $archive = Archive::read(PDF); From c40f9c7a42a87c16e31af4d956452fa0abb68fc5 Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:27:56 +0100 Subject: [PATCH 2/8] Add 7z installation command to macOS workflow --- .github/workflows/run-macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-macos.yml b/.github/workflows/run-macos.yml index 15a1808..9f38dbd 100644 --- a/.github/workflows/run-macos.yml +++ b/.github/workflows/run-macos.yml @@ -19,6 +19,7 @@ jobs: brew install rar brew install ghostscript brew install imagemagick + which 7z shell: bash - name: Setup PHP From 93dc941c7c55c81ad32b13e3a30b2a455b7a037e Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:29:45 +0100 Subject: [PATCH 3/8] Update README.md with supported file types and requirements --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ff88a3c..180254d 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,15 @@ Supports Linux, macOS and Windows. - [`imagick`](https://www.php.net/manual/en/book.imagick.php) (optional) for `.PDF` - [`bz2`](https://www.php.net/manual/en/book.bzip2.php) (optional) for `.BZ2` archives -| Type | Supported | Requirement | Uses | -| :-----------------------: | :-------: | :------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------: | -| `.zip`, `.epub`, `.cbz` | ✅ | N/A | Uses [`zip` extension](https://www.php.net/manual/en/book.zip.php) | -| `.tar`, `.tar.gz`, `.cbt` | ✅ | N/A | Uses [`phar` extension](https://www.php.net/manual/en/book.phar.php) | -| `.rar`, `.cbr` | ✅ | [`rar` PHP extension](https://github.com/cataphract/php-rar) or [`p7zip`](https://www.7-zip.org/) binary | PHP `rar` or `p7zip` | -| `.7z`, `.cb7` | ✅ | [`p7zip`](https://www.7-zip.org/) binary | `p7zip` binary | -| `.pdf` | ✅ | Optional (for extraction) [`imagick` PHP extension](https://github.com/Imagick/imagick) | `smalot/pdfparser` | +| Type | Supported | Requirement | Uses | +| :-----------------------: | :-------: | :------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------: | +| `.zip`, `.epub`, `.cbz` | ✅ | N/A | Uses [`zip` extension](https://www.php.net/manual/en/book.zip.php) | +| `.tar`, `.tar.gz`, `.cbt` | ✅ | N/A | Uses [`phar` extension](https://www.php.net/manual/en/book.phar.php)\* | +| `.rar`, `.cbr` | ✅ | [`rar` PHP extension](https://github.com/cataphract/php-rar) or [`p7zip`](https://www.7-zip.org/) binary | PHP `rar` or `p7zip` | +| `.7z`, `.cb7` | ✅ | [`p7zip`](https://www.7-zip.org/) binary | `p7zip` binary | +| `.pdf` | ✅ | Optional (for extraction) [`imagick` PHP extension](https://github.com/Imagick/imagick) | `smalot/pdfparser` | + +\*: for `.tar` archives with password, `.7z` will be used because extension don't support password. > [!NOTE] > From dfdef6221a5a8d2a651cd5e179bc172690d9f967 Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:31:23 +0100 Subject: [PATCH 4/8] Add 7z command to install dependencies --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f0817c7..de01f57 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,6 +22,7 @@ jobs: sudo apt install -y unrar sudo apt install -y libunrar-dev sudo sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml + which 7z shell: bash - name: Checkout code From c8d69298b649f3f049cc2dde4974008a3d75a756 Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:32:42 +0100 Subject: [PATCH 5/8] Update binary path for macOS and Linux --- tests/ArchiveTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ArchiveTest.php b/tests/ArchiveTest.php index 0b04ce5..a60c007 100644 --- a/tests/ArchiveTest.php +++ b/tests/ArchiveTest.php @@ -162,8 +162,10 @@ function (Pest\Expectation $item) use ($ext) { if (PHP_OS_FAMILY === 'Windows') { $current_user = exec('echo %USERNAME%'); $binary_path = "C:\\Users\\{$current_user}\\scoop\\apps\\7zip\\current\\7z.exe"; - } else { + } elseif (PHP_OS_FAMILY === 'Darwin') { $binary_path = '/opt/homebrew/bin/7z'; + } else { + $binary_path = '/usr/bin/7z'; } $archive = Archive::read($path)->overrideBinaryPath($binary_path); From fe0f398e2e9c718b70eea96fcaa8f8ef8578091a Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:33:17 +0100 Subject: [PATCH 6/8] Refactor code to improve performance and readability --- .github/workflows/run-macos.yml | 1 - .github/workflows/run-tests.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/run-macos.yml b/.github/workflows/run-macos.yml index 9f38dbd..15a1808 100644 --- a/.github/workflows/run-macos.yml +++ b/.github/workflows/run-macos.yml @@ -19,7 +19,6 @@ jobs: brew install rar brew install ghostscript brew install imagemagick - which 7z shell: bash - name: Setup PHP diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index de01f57..f0817c7 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,7 +22,6 @@ jobs: sudo apt install -y unrar sudo apt install -y libunrar-dev sudo sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml - which 7z shell: bash - name: Checkout code From 973d753b57928afda6c163d7c26701a3821b09a6 Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:37:14 +0100 Subject: [PATCH 7/8] Add getFileItem() method to list files by path --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 180254d..ee9e01f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ If you want more information, you can read section [**About**](#about). - List files as `ArchiveItem` array - With `getFileItems()` method: list of files + - With `getFileItem(string $path)` method: file corresponding to `path` property - With `getFirst()` method: first file - With `getLast()` method: last file - With `find()` method: find first file that match with `path` property From 464f6b4bcebb3dc75531890a2694784afa2d4945 Mon Sep 17 00:00:00 2001 From: Ewilan Riviere Date: Fri, 8 Mar 2024 11:39:09 +0100 Subject: [PATCH 8/8] Update contributor name in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee9e01f..de58793 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Supports Linux, macOS and Windows. | `.tar`, `.tar.gz`, `.cbt` | ✅ | N/A | Uses [`phar` extension](https://www.php.net/manual/en/book.phar.php)\* | | `.rar`, `.cbr` | ✅ | [`rar` PHP extension](https://github.com/cataphract/php-rar) or [`p7zip`](https://www.7-zip.org/) binary | PHP `rar` or `p7zip` | | `.7z`, `.cb7` | ✅ | [`p7zip`](https://www.7-zip.org/) binary | `p7zip` binary | -| `.pdf` | ✅ | Optional (for extraction) [`imagick` PHP extension](https://github.com/Imagick/imagick) | `smalot/pdfparser` | +| `.pdf` | ✅ | Optional (for extraction) [`imagick` PHP extension](https://github.com/Imagick/imagick) | [`smalot/pdfparser`](https://github.com/smalot/pdfparser) | \*: for `.tar` archives with password, `.7z` will be used because extension don't support password. @@ -277,7 +277,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re ## Credits -- [Kiwilan](https://github.com/kiwilan) +- [Ewilan Riviere](https://github.com/ewilan-riviere) - [All Contributors](../../contributors) - [spatie](https://github.com/spatie) for `spatie/package-skeleton-php` and `spatie/temporary-directory` - [`smalot/pdfparser`](https://github.com/smalot/pdfparser) for PDF parser