diff --git a/dev/phpstan.sh b/dev/phpstan.sh index f9e7e43242..079234356b 100755 --- a/dev/phpstan.sh +++ b/dev/phpstan.sh @@ -5,7 +5,7 @@ cd "$__DIR__/.." __DIR__=$(pwd) components=( - "core" +# "core" 默认不处理 "access-control" "amqp" "apidoc" @@ -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" diff --git a/dev/rector.sh b/dev/rector.sh new file mode 100644 index 0000000000..c0ef54c3df --- /dev/null +++ b/dev/rector.sh @@ -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 \ No newline at end of file diff --git a/rector.sh b/rector.sh deleted file mode 100755 index c6473da6f4..0000000000 --- a/rector.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -__DIR__=$(cd `dirname $0`; pwd) - -cd $__DIR__ && echo "core" && ./vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/access-control && echo "access-control" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/amqp && echo "amqp" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/apidoc && echo "apidoc" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/fpm && echo "fpm" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/grpc && echo "grpc" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/jwt && echo "jwt" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/kafka && echo "kafka" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/mqtt && echo "mqtt" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/pgsql && echo "pgsql" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/queue && echo "queue" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/rate-limit && echo "rate-limit" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/roadrunner && echo "roadrunner" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/rpc && echo "rpc" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/shared-memory && echo "shared-memory" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/smarty && echo "smarty" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/snowflake && echo "snowflake" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/swoole && echo "swoole" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/swoole-tracker && echo "swoole-tracker" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/workerman && echo "workerman" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/workerman-gateway && echo "workerman-gateway" && ../../../vendor/bin/rector process --dry-run -cd $__DIR__/src/Components/macro && echo "macro" && ../../../vendor/bin/rector process --dry-run \ No newline at end of file