Skip to content

Commit

Permalink
Update: 更新工具脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Oct 19, 2023
1 parent 2db0c80 commit 83f6839
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 28 deletions.
4 changes: 2 additions & 2 deletions dev/phpstan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cd "$__DIR__/.."
__DIR__=$(pwd)

components=(
"core"
# "core" 默认不处理
"access-control"
"amqp"
"apidoc"
Expand Down Expand Up @@ -81,7 +81,7 @@ if [ ${#input_components[@]} -eq 0 ]; then
else
# Analyze the specified components provided as arguments
for component in "${input_components[@]}"; do
if [[ " ${components[@]} " =~ " $component " ]]; then
if [[ " ${components[@]} " =~ " $component " || "core" == "$component" ]]; then
analyze_component "$component" "$use_baseline"
else
echo "Invalid component name: $component"
Expand Down
91 changes: 91 additions & 0 deletions dev/rector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

__DIR__=$(cd `dirname $0`; pwd)
cd "$__DIR__/.."
__DIR__=$(pwd)

components=(
# "core" 默认不处理
"access-control"
"amqp"
"apidoc"
"fpm"
"grpc"
"jwt"
"kafka"
"mqtt"
"pgsql"
"queue"
"rate-limit"
"roadrunner"
"rpc"
"shared-memory"
"smarty"
"snowflake"
"swoole"
"swoole-tracker"
"workerman"
"workerman-gateway"
"macro"
)

analyze_component() {
component="$1"
use_dry_run="$2"
original_dir=$(pwd)
echo "process: $component, dry-run: $use_dry_run"

analyse_configuration=""

args=()

if [ "$component" != "core" ]; then
cd "$__DIR__/src/Components/$component"
fi

if [ "$use_dry_run" == "true" ]; then
args+=("--dry-run")
fi

"$__DIR__/vendor/bin/rector" process "${args[@]}"

cd "$original_dir"
sleep 1
}

use_dry_run="false"
input_components=()

while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run)
use_dry_run="true"
shift
;;
-n)
use_dry_run="true"
shift
;;
*)
# 如果不是 --dry-run 标志,将参数添加到 components 数组中
input_components+=("$1")
shift
;;
esac
done

if [ ${#input_components[@]} -eq 0 ]; then
# If no arguments are provided, analyze all components
for component in "${components[@]}"; do
analyze_component "$component" "$use_dry_run"
done
else
# Analyze the specified components provided as arguments
for component in "${input_components[@]}"; do
if [[ " ${components[@]} " =~ " $component " || "core" == "$component" ]]; then
analyze_component "$component" "$use_dry_run"
else
echo "Invalid component name: $component"
fi
done
fi
26 changes: 0 additions & 26 deletions rector.sh

This file was deleted.

0 comments on commit 83f6839

Please sign in to comment.