From 14409e87c010421ce9919b5ea6ad7ab9c35b5e8c Mon Sep 17 00:00:00 2001 From: macocci7 Date: Fri, 21 Nov 2025 13:57:30 +0900 Subject: [PATCH 1/4] Support PHP 8.5 --- PHP_VERSIONS | 1 + bin/TestAndLint.sh | 39 +++++++++++++++++++---- bin/TestAndLintSub.sh | 26 --------------- bin_/CheckVersion.sh | 35 +++++++++++++++++++++ bin_/TestAndLint.sh | 73 +++++++++++++++++++++++++++++++++++++++++++ composer.json | 2 +- 6 files changed, 143 insertions(+), 33 deletions(-) delete mode 100644 bin/TestAndLintSub.sh create mode 100644 bin_/CheckVersion.sh create mode 100644 bin_/TestAndLint.sh diff --git a/PHP_VERSIONS b/PHP_VERSIONS index 75df3c4..2563267 100644 --- a/PHP_VERSIONS +++ b/PHP_VERSIONS @@ -1,3 +1,4 @@ +8.5 8.4 8.3 8.2 diff --git a/bin/TestAndLint.sh b/bin/TestAndLint.sh index 4a3b743..9609a43 100644 --- a/bin/TestAndLint.sh +++ b/bin/TestAndLint.sh @@ -5,7 +5,7 @@ # - https://github.com/jdx/mise installed # - PHP versions defined in ../PHP_VERSIONS installed -CMD=mise +CMD=phpenv $CMD -v &> /dev/null if [ $? -ne 0 ]; then echo "command [${CMD}] not found!" @@ -19,13 +19,40 @@ if [ $? -ne 0 ]; then exit 1 fi -switch_version() { +test_and_lint() { echo "===========================================================" - echo "[PHP $1][Switching PHP version to $1]" - mise x php@$1 -- bash bin/TestAndLintSub.sh $1; + echo "[PHP $1][phpenv local $1]" + phpenv local $1 + if [ $? -ne 0 ]; then + echo "Failed to switch version to $1. skipped." + return 1 + fi + echo "-----------------------------------------------------------" + echo "[PHP $1][php -v]" + php -v + echo "-----------------------------------------------------------" + echo "[PHP $1][parallel-lint]" + ./vendor/bin/parallel-lint src tests + #echo "-----------------------------------------------------------" + #echo "[PHP $1][neon-lint]" + #./vendor/nette/neon/bin/neon-lint conf + echo "-----------------------------------------------------------" + echo "[PHP $1][phpcs]" + ./vendor/bin/phpcs --ignore=vendor \ + --standard=phpcs.xml \ + -p \ + -s \ + . + echo "-----------------------------------------------------------" + echo "[PHP $1][phpstan]" + ./vendor/bin/phpstan analyze -c phpstan.neon + echo "-----------------------------------------------------------" + echo "[PHP $1][phpunit]" + ./vendor/bin/phpunit ./tests/ + echo "-----------------------------------------------------------" } -echo "[[TestAndLint.sh]]" +echo "[[TesAndLint.sh]]" SUPPORTED_PHP_VERSIONS=PHP_VERSIONS if [ ! -f $SUPPORTED_PHP_VERSIONS ]; then @@ -40,6 +67,6 @@ if [ ! -r $SUPPORTED_PHP_VERSIONS ]; then fi STR_CMD='' while read version ; do - STR_CMD="$STR_CMD switch_version $version;" + STR_CMD="$STR_CMD test_and_lint $version;" done < $SUPPORTED_PHP_VERSIONS eval $STR_CMD diff --git a/bin/TestAndLintSub.sh b/bin/TestAndLintSub.sh deleted file mode 100644 index c395c39..0000000 --- a/bin/TestAndLintSub.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/bash - -# Script to Test and Lint -# requirement: -# - PHP versions defined in ../PHP_VERSIONS installed - -echo "-----------------------------------------------------------" -echo "[PHP $1][php -v]" -php -v -echo "-----------------------------------------------------------" -echo "[PHP $1][parallel-lint]" -./vendor/bin/parallel-lint src tests playground -echo "-----------------------------------------------------------" -echo "[PHP $1][phpcs]" -./vendor/bin/phpcs --ignore=vendor \ - --standard=phpcs.xml \ - -p \ - -s \ - . -echo "-----------------------------------------------------------" -echo "[PHP $1][phpstan]" -./vendor/bin/phpstan analyze -c phpstan.neon -echo "-----------------------------------------------------------" -echo "[PHP $1][phpunit]" -./vendor/bin/phpunit ./tests/ -echo "-----------------------------------------------------------" diff --git a/bin_/CheckVersion.sh b/bin_/CheckVersion.sh new file mode 100644 index 0000000..48f03e1 --- /dev/null +++ b/bin_/CheckVersion.sh @@ -0,0 +1,35 @@ +#!/usr/bin/bash + +# Script to check +# if the version in composer.json +# is not in git tags + +if [ ! -r composer.json ]; then + echo "composer.json not found." + echo "operation aborted." + exit 1 +fi + +VERSION=$(cat composer.json | grep version | head -1 | grep -Po '\d+\.\d+\.\d+') +printf 'version in composer.json: \033[1;33m%s\033[m\n' $VERSION + + +show_latest_tags() { + echo "The latest $1 tags are:" + for tag in `git tag | sort | tail -$1` + do + printf '\033[93m%s\033[m\n' $tag + done +} + +for tag in `git tag` +do + if [ $tag = $VERSION ]; then + printf '\033[41m Error! version %s already exists in git tags. \033[m\n' $VERSION + show_latest_tags 3 + exit 1 + fi +done +printf '\033[1;102m%s\033[m\n' " OK! versoin $VERSION is not in git tags. " +show_latest_tags 3 +printf '\033[93m%s\033[m\n' "Don't forget to run \`composer update\` before commit." diff --git a/bin_/TestAndLint.sh b/bin_/TestAndLint.sh new file mode 100644 index 0000000..4330fee --- /dev/null +++ b/bin_/TestAndLint.sh @@ -0,0 +1,73 @@ +#!/usr/bin/bash + +# Script to Test and Lint +# - for the repository: macocci7/php-lorenz-curve +# requirement: +# - phpenv/phpenv +# - PHP versions defined in ../PHP_VERSIONS installed + +CMD=phpenv +$CMD -v &> /dev/null +if [ $? -ne 0 ]; then + echo "command [${CMD}] not found!" + exit 1 +fi +echo "-----------------------------------------------------------" +echo "[composer validate]" +composer validate +if [ $? -ne 0 ]; then + echo "Operation aborted." + exit 1 +fi + +test_and_lint() { + echo "===========================================================" + echo "[PHP $1][phpenv local $1]" + phpenv local $1 + if [ $? -ne 0 ]; then + echo "Failed to switch version to $1. skipped." + return 1 + fi + echo "-----------------------------------------------------------" + echo "[PHP $1][php -v]" + php -v + echo "-----------------------------------------------------------" + echo "[PHP $1][parallel-lint]" + ./vendor/bin/parallel-lint src tests examples + echo "-----------------------------------------------------------" + echo "[PHP $1][neon-lint]" + ./vendor/nette/neon/bin/neon-lint conf + echo "-----------------------------------------------------------" + echo "[PHP $1][phpcs]" + ./vendor/bin/phpcs --ignore=vendor \ + --standard=phpcs.xml \ + -p \ + -s \ + . + echo "-----------------------------------------------------------" + echo "[PHP $1][phpstan]" + ./vendor/bin/phpstan analyze -c phpstan.neon + echo "-----------------------------------------------------------" + echo "[PHP $1][phpunit]" + ./vendor/bin/phpunit ./tests/ + echo "-----------------------------------------------------------" +} + +echo "[[TesAndLint.sh]]" + +SUPPORTED_PHP_VERSIONS=PHP_VERSIONS +if [ ! -f $SUPPORTED_PHP_VERSIONS ]; then + echo "file [$SUPPORTED_PHP_VERSIONS] not found." + echo "operation aborted." + exit 1 +fi +if [ ! -r $SUPPORTED_PHP_VERSIONS ]; then + echo "cannot read file[$SUPPORTED_PHP_VERSIONS]." + echo "operation aborted." + exit 1 +fi +STR_CMD='' +while read version ; do + STR_CMD="$STR_CMD test_and_lint $version;" +done < $SUPPORTED_PHP_VERSIONS +eval $STR_CMD diff --git a/composer.json b/composer.json index eae45bf..fbc33e1 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require-dev": { "phpunit/phpunit": "^10.5", "php-parallel-lint/php-parallel-lint": "^1.4", - "squizlabs/php_codesniffer": "^3.12", + "squizlabs/php_codesniffer": "^4", "phpstan/phpstan": "^2.1" } } From 3dcd1fc63399e234a79a3c87b9aea32facb5968e Mon Sep 17 00:00:00 2001 From: macocci7 Date: Fri, 21 Nov 2025 14:00:20 +0900 Subject: [PATCH 2/4] remove debug files --- bin_/CheckVersion.sh | 35 --------------------- bin_/TestAndLint.sh | 73 -------------------------------------------- 2 files changed, 108 deletions(-) delete mode 100644 bin_/CheckVersion.sh delete mode 100644 bin_/TestAndLint.sh diff --git a/bin_/CheckVersion.sh b/bin_/CheckVersion.sh deleted file mode 100644 index 48f03e1..0000000 --- a/bin_/CheckVersion.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/bash - -# Script to check -# if the version in composer.json -# is not in git tags - -if [ ! -r composer.json ]; then - echo "composer.json not found." - echo "operation aborted." - exit 1 -fi - -VERSION=$(cat composer.json | grep version | head -1 | grep -Po '\d+\.\d+\.\d+') -printf 'version in composer.json: \033[1;33m%s\033[m\n' $VERSION - - -show_latest_tags() { - echo "The latest $1 tags are:" - for tag in `git tag | sort | tail -$1` - do - printf '\033[93m%s\033[m\n' $tag - done -} - -for tag in `git tag` -do - if [ $tag = $VERSION ]; then - printf '\033[41m Error! version %s already exists in git tags. \033[m\n' $VERSION - show_latest_tags 3 - exit 1 - fi -done -printf '\033[1;102m%s\033[m\n' " OK! versoin $VERSION is not in git tags. " -show_latest_tags 3 -printf '\033[93m%s\033[m\n' "Don't forget to run \`composer update\` before commit." diff --git a/bin_/TestAndLint.sh b/bin_/TestAndLint.sh deleted file mode 100644 index 4330fee..0000000 --- a/bin_/TestAndLint.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/bash - -# Script to Test and Lint -# - for the repository: macocci7/php-lorenz-curve -# requirement: -# - phpenv/phpenv -# - PHP versions defined in ../PHP_VERSIONS installed - -CMD=phpenv -$CMD -v &> /dev/null -if [ $? -ne 0 ]; then - echo "command [${CMD}] not found!" - exit 1 -fi -echo "-----------------------------------------------------------" -echo "[composer validate]" -composer validate -if [ $? -ne 0 ]; then - echo "Operation aborted." - exit 1 -fi - -test_and_lint() { - echo "===========================================================" - echo "[PHP $1][phpenv local $1]" - phpenv local $1 - if [ $? -ne 0 ]; then - echo "Failed to switch version to $1. skipped." - return 1 - fi - echo "-----------------------------------------------------------" - echo "[PHP $1][php -v]" - php -v - echo "-----------------------------------------------------------" - echo "[PHP $1][parallel-lint]" - ./vendor/bin/parallel-lint src tests examples - echo "-----------------------------------------------------------" - echo "[PHP $1][neon-lint]" - ./vendor/nette/neon/bin/neon-lint conf - echo "-----------------------------------------------------------" - echo "[PHP $1][phpcs]" - ./vendor/bin/phpcs --ignore=vendor \ - --standard=phpcs.xml \ - -p \ - -s \ - . - echo "-----------------------------------------------------------" - echo "[PHP $1][phpstan]" - ./vendor/bin/phpstan analyze -c phpstan.neon - echo "-----------------------------------------------------------" - echo "[PHP $1][phpunit]" - ./vendor/bin/phpunit ./tests/ - echo "-----------------------------------------------------------" -} - -echo "[[TesAndLint.sh]]" - -SUPPORTED_PHP_VERSIONS=PHP_VERSIONS -if [ ! -f $SUPPORTED_PHP_VERSIONS ]; then - echo "file [$SUPPORTED_PHP_VERSIONS] not found." - echo "operation aborted." - exit 1 -fi -if [ ! -r $SUPPORTED_PHP_VERSIONS ]; then - echo "cannot read file[$SUPPORTED_PHP_VERSIONS]." - echo "operation aborted." - exit 1 -fi -STR_CMD='' -while read version ; do - STR_CMD="$STR_CMD test_and_lint $version;" -done < $SUPPORTED_PHP_VERSIONS -eval $STR_CMD From 30fb66eebe13174b5d134aea03e2c07fade64ca8 Mon Sep 17 00:00:00 2001 From: macocci7 Date: Fri, 21 Nov 2025 14:32:38 +0900 Subject: [PATCH 3/4] Update README --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e13f4fc..031530f 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,19 @@ ## 1. Features -`Bash Colorizer` outputs strings in specified colors and attributes. +`Bash Colorizer` outputs strings to the bash terminal with specified colors and attributes. Let's make your `bash` terminal full of colors! +```php +use Macocci7\BashColorizer\Colorizer; + +Colorizer::attributes(['italic']) + ->foreground('#ffff00') + ->background('#0000ff') + ->echo('Hi, there!', PHP_EOL); +``` + ## 2. Contents - [1. Features](#1-features) @@ -31,7 +40,7 @@ Let's make your `bash` terminal full of colors! - PHP 8.1 or later installed - Composer v2 installed -- Bash v5 installed +- Bash v5 installed (or Zsh) ## 5. Installation From ab42910813d471705ebf4a097d2bf63ce7dcdb35 Mon Sep 17 00:00:00 2001 From: macocci7 Date: Fri, 21 Nov 2025 14:36:56 +0900 Subject: [PATCH 4/4] Update github workflow --- .github/workflows/test_pull_request.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_pull_request.yml b/.github/workflows/test_pull_request.yml index 56f4132..073b673 100644 --- a/.github/workflows/test_pull_request.yml +++ b/.github/workflows/test_pull_request.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.1', '8.2', '8.3', '8.4'] + php: ['8.1', '8.2', '8.3', '8.4', '8.5'] steps: - name: Set up PHP @@ -19,12 +19,12 @@ jobs: tools: composer:v2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: '22.x' + node-version: '24.x' - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 @@ -74,12 +74,12 @@ jobs: tools: composer:v2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: '22.x' + node-version: '24.x' - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0