Skip to content

Commit 02f78aa

Browse files
committed
👔 up: update dep version, and add some new class
1 parent efc832d commit 02f78aa

10 files changed

+474
-866
lines changed

.github/changelog.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
title: '## Change Log'
2+
# style allow: simple, markdown(mkdown), ghr(gh-release)
3+
style: gh-release
4+
# group names
5+
names: [Refactor, Fixed, Feature, Update, Other]
6+
# if empty will auto fetch by git remote
7+
#repo_url: https://github.com/gookit/gitw
8+
9+
filters:
10+
# message length should >= 12
11+
- name: msg_len
12+
min_len: 12
13+
# message words should >= 3
14+
- name: words_len
15+
min_len: 3
16+
- name: keyword
17+
keyword: format code
18+
exclude: true
19+
- name: keywords
20+
keywords: format code, action test
21+
exclude: true
22+
23+
# group match rules
24+
# not matched will use 'Other' group.
25+
rules:
26+
- name: Refactor
27+
start_withs: [refactor, break]
28+
contains: ['refactor:']
29+
- name: Fixed
30+
start_withs: [fix]
31+
contains: ['fix:']
32+
- name: Feature
33+
start_withs: [feat, new]
34+
contains: ['feat:']
35+
- name: Update
36+
start_withs: [update]
37+
contains: ['update:', 'up:']

.github/workflows/php.yml

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
name: Unit-tests
1+
name: Unit-Tests
22

33
on: [push]
44

55
jobs:
66
test:
7-
name: Test on php ${{ matrix.php}} and ${{ matrix.os }}
8-
runs-on: ${{ matrix.os }}
7+
name: Test on php ${{ matrix.php }}
8+
runs-on: ubuntu-latest
99
timeout-minutes: 10
1010
strategy:
1111
fail-fast: true
1212
matrix:
13-
php: [7.3, 7.4, 8.0] #
14-
os: [ubuntu-latest, macOS-latest] # windows-latest,
15-
include:
16-
- os: 'ubuntu-latest'
17-
php: '7.2'
18-
phpunit: '8.5.13'
13+
php: [8.1, 8.2, 8.3]
14+
# os: [ubuntu-latest, macOS-latest] # windows-latest,
1915

2016
steps:
2117
- name: Checkout
@@ -27,16 +23,17 @@ jobs:
2723
uses: shivammathur/setup-php@v2
2824
with:
2925
php-version: ${{ matrix.php}}
30-
tools: pecl, php-cs-fixer, phpunit:${{ matrix.phpunit }}
31-
extensions: mbstring, dom, fileinfo, mysql, openssl, igbinary, redis # , swoole-4.4.19 #optional, setup extensions
26+
tools: pecl, php-cs-fixer, phpunit # , phpunit-7.5
27+
extensions: mbstring, dom, fileinfo, openssl, igbinary # , swoole-4.4.19 #optional, setup extensions
3228
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
3329
coverage: none #optional, setup coverage driver: xdebug, none
3430

3531
- name: Display Env
3632
run: env
3733

3834
- name: Install dependencies
39-
run: composer install --no-progress --no-suggest
35+
run: |
36+
composer install --no-progress --no-suggest
4037
4138
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
4239
# Docs: https://getcomposer.org/doc/articles/scripts.md

.github/workflows/release.yml

+14-36
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,34 @@ on:
77

88
jobs:
99
release:
10-
name: Test on php ${{ matrix.php}}
10+
name: Tag release
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 10
13-
strategy:
14-
fail-fast: true
15-
matrix:
16-
php: [7.3]
1713

1814
steps:
1915
- name: Checkout
2016
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
2119

2220
- name: Set ENV for github-release
2321
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
2422
run: |
2523
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
2624
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
2725
28-
# usage refer https://github.com/shivammathur/setup-php
29-
- name: Setup PHP
30-
timeout-minutes: 5
31-
uses: shivammathur/setup-php@v2
32-
with:
33-
php-version: ${{ matrix.php}}
34-
tools: pecl, php-cs-fixer, phpunit
35-
extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions
36-
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
37-
coverage: none #optional, setup coverage driver: xdebug, none
38-
39-
- name: Install dependencies # eg: v1.0.3
26+
- name: Generate changelog
4027
run: |
41-
tag1=${GITHUB_REF#refs/*/}
42-
echo "release tag: ${tag1}"
43-
composer install --no-progress --no-suggest
44-
45-
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
46-
# Docs: https://getcomposer.org/doc/articles/scripts.md
47-
48-
# - name: Build phar and send to github assets
49-
# run: |
50-
# echo $RELEASE_TAG
51-
# echo $RELEASE_NAME
52-
# php -d phar.readonly=0 bin/kite phar:pack -o kite-${RELEASE_TAG}.phar --no-progress
53-
# php kite-${RELEASE_TAG}.phar -V
28+
curl https://github.com/gookit/gitw/releases/latest/download/chlog-linux-amd64 -L -o /usr/local/bin/chlog
29+
chmod a+x /usr/local/bin/chlog
30+
chlog -c .github/changelog.yml -o changelog.md prev last
5431
55-
# https://github.com/actions/create-release
56-
- uses: meeDamian/[email protected]
32+
# https://github.com/softprops/action-gh-release
33+
- name: Create release and upload assets
34+
uses: softprops/action-gh-release@v2
5735
with:
58-
gzip: false
59-
token: ${{ secrets.GITHUB_TOKEN }}
60-
tag: ${{ env.RELEASE_TAG }}
6136
name: ${{ env.RELEASE_TAG }}
62-
# files: kite-${{ env.RELEASE_TAG }}.phar
37+
tag_name: ${{ env.RELEASE_TAG }}
38+
body_path: changelog.md
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
Some useful extends library for php.
99

10+
11+
1012
## Install
1113

1214
```bash

composer.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">7.1.0",
22-
"toolkit/cli-utils": "^1.0",
23-
"toolkit/fsutil": "^1.0",
24-
"toolkit/stdlib": "^1.0"
21+
"php": ">=8.1.0",
22+
"toolkit/cli-utils": "~2.0",
23+
"toolkit/fsutil": "~2.0",
24+
"toolkit/stdlib": "~2.0",
25+
"toolkit/sys-utils": "~2.0"
2526
},
2627
"autoload": {
2728
"psr-4": {

phpunit.xml

+7-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
bootstrap="test/boot.php"
6-
colors="false"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
stopOnFailure="false"
11-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="test/bootstrap.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
123
<testsuites>
13-
<testsuite name="php-comp http-client Test Suite">
4+
<testsuite name="Php Library Test Suite">
145
<directory>test</directory>
156
</testsuite>
167
</testsuites>
17-
18-
<filter>
19-
<whitelist>
8+
<coverage/>
9+
<source>
10+
<include>
2011
<directory suffix=".php">src</directory>
21-
</whitelist>
22-
</filter>
12+
</include>
13+
</source>
2314
</phpunit>

src/Exec/Cmd.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Toolkit\Extlib\Exec;
4+
5+
use Toolkit\Cli\Color;
6+
use Toolkit\Sys\Cmd\CmdBuilder;
7+
8+
/**
9+
* class Cmd builder
10+
*/
11+
class Cmd extends CmdBuilder
12+
{
13+
/**
14+
* @param string $msg
15+
* @param string $scene
16+
*/
17+
protected function printMessage(string $msg, string $scene): void
18+
{
19+
self::printByScene($msg, $scene);
20+
}
21+
22+
/**
23+
* @param string $msg
24+
* @param string $scene
25+
*/
26+
public static function printByScene(string $msg, string $scene): void
27+
{
28+
$color = 'info';
29+
if ($scene === self::PRINT_CMD) {
30+
$color = 'yellow';
31+
} elseif ($scene === self::PRINT_DRY_RUN) {
32+
$color = 'cyan';
33+
} elseif ($scene === self::PRINT_ERROR) {
34+
$color = 'red';
35+
}
36+
37+
Color::println($msg, $color);
38+
}
39+
}

0 commit comments

Comments
 (0)