From 97cd694ff44b6d48a4bd84aa5569d7c4e661ab1f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 29 Sep 2026 19:02:16 +0200 Subject: [PATCH] Drop standalone blink bin, make --blink the only entry point Running vendor/bin/blink directly scans the whole working directory with all fixers and ignores the project ecs.php, which is easy to trigger by accident. Remove it so blink is reached only through 'ecs check --blink', which feeds the resolved ecs.php (paths, skips, rules) to the binary. - remove bin/blink from the dev and published composer bin, delete the wrapper - EcsGoBinaryLocator drops the vendor/bin/blink lookup - turbo CI builds blink from the local blink/ module instead of cloning the external repo --- .github/workflows/buid_release.yaml | 1 - .github/workflows/turbo.yaml | 15 ++++------ bin/blink | 41 --------------------------- build/target-repository/composer.json | 3 +- composer.json | 3 +- src/Turbo/EcsGoBinaryLocator.php | 7 +---- 6 files changed, 9 insertions(+), 61 deletions(-) delete mode 100755 bin/blink diff --git a/.github/workflows/buid_release.yaml b/.github/workflows/buid_release.yaml index f4ec06ff27..f1a946cd3a 100644 --- a/.github/workflows/buid_release.yaml +++ b/.github/workflows/buid_release.yaml @@ -73,7 +73,6 @@ jobs: # make bin files runnable without "php" chmod 777 ecs-prefixed-downgraded/bin/ecs chmod 777 ecs-prefixed-downgraded/bin/ecs.php - chmod 777 ecs-prefixed-downgraded/bin/blink # 4. lint the code for PHP 7.4 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434 - diff --git a/.github/workflows/turbo.yaml b/.github/workflows/turbo.yaml index 1d73553b85..691dc2d59f 100644 --- a/.github/workflows/turbo.yaml +++ b/.github/workflows/turbo.yaml @@ -1,9 +1,9 @@ name: Turbo # End-to-end check of --blink: ECS dumps the resolved ecs.php config to JSON and -# hands it to the ecs-go binary, which maps the rules and rewrites the code. This -# builds ecs-go from source, runs --blink --fix over a golden fixture, and asserts -# the output matches the expected result. +# hands it to the blink binary, which maps the rules and rewrites the code. This +# builds blink from the local blink/ module, runs --blink --fix over a golden +# fixture, and asserts the output matches the expected result. on: pull_request: @@ -32,17 +32,14 @@ jobs: go-version: "1.26.6" - - name: "Build the ecs-go binary from source" - run: | - git clone --depth 1 https://github.com/TomasVotruba/ecs-go.git /tmp/ecs-go - cd /tmp/ecs-go/ecs-go - go build -o /tmp/ecs-go-bin . + name: "Build the blink binary from the local blink/ module" + run: go build -C blink -o /tmp/blink-bin . - name: "Run --blink --fix over the golden fixture" run: | cp -r tests/Turbo/Fixture/input /tmp/turbo-work - ECS_TURBO_BIN=/tmp/ecs-go-bin bin/ecs check /tmp/turbo-work --blink --fix \ + ECS_TURBO_BIN=/tmp/blink-bin bin/ecs check /tmp/turbo-work --blink --fix \ --config=tests/Turbo/Fixture/ecs.php --no-progress-bar --ansi || true - diff --git a/bin/blink b/bin/blink deleted file mode 100755 index 7b14f66aa1..0000000000 --- a/bin/blink +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env sh -# Composer bin wrapper for blink, the Go coding-standard tool. -# In a release it execs the bundled per-platform binary (bin/blink--). -# In the source repo it builds from blink/ on first run (Go required). -set -e - -DIR="$(cd "$(dirname "$0")" && pwd)" - -os=$(uname -s) -arch=$(uname -m) -case "$os" in - Linux) os=linux ;; - Darwin) os=darwin ;; - *) os= ;; -esac -case "$arch" in - x86_64 | amd64) arch=amd64 ;; - aarch64 | arm64) arch=arm64 ;; - *) arch= ;; -esac - -if [ -n "$os" ] && [ -n "$arch" ] && [ -x "$DIR/blink-$os-$arch" ]; then - exec "$DIR/blink-$os-$arch" "$@" -fi - -# source checkout: build from the blink/ Go module -SRC="$DIR/../blink" -if [ -d "$SRC" ]; then - BINARY="$SRC/blink" - if [ ! -x "$BINARY" ]; then - if ! command -v go >/dev/null 2>&1; then - echo "blink: Go toolchain required to build from source (https://go.dev/dl)" >&2 - exit 1 - fi - (cd "$SRC" && go build -o "$BINARY" .) - fi - exec "$BINARY" "$@" -fi - -echo "blink: no bundled binary for $os-$arch and no blink/ source to build from" >&2 -exit 1 diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index 116cf4e5f0..09c7726ea0 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -4,8 +4,7 @@ "license": "MIT", "keywords": ["static analysis", "code style", "automation", "fixer"], "bin": [ - "bin/ecs", - "bin/blink" + "bin/ecs" ], "require": { "php": ">=7.2" diff --git a/composer.json b/composer.json index 53bd07ae0a..33febc7983 100644 --- a/composer.json +++ b/composer.json @@ -9,8 +9,7 @@ "fixer" ], "bin": [ - "bin/ecs", - "bin/blink" + "bin/ecs" ], "require": { "php": ">=8.4", diff --git a/src/Turbo/EcsGoBinaryLocator.php b/src/Turbo/EcsGoBinaryLocator.php index 6caa338d8e..4260e552a0 100644 --- a/src/Turbo/EcsGoBinaryLocator.php +++ b/src/Turbo/EcsGoBinaryLocator.php @@ -38,18 +38,13 @@ public function locate(): string return $bundledBinary; } - $vendorBinary = getcwd() . '/vendor/bin/blink'; - if (is_file($vendorBinary)) { - return $vendorBinary; - } - $pathBinary = $this->findOnPath('blink'); if ($pathBinary !== null) { return $pathBinary; } throw new EcsGoBinaryNotFoundException(sprintf( - 'The blink binary for --blink was not found in "%s" env, "vendor/bin/blink" or on PATH. Build it with "go build" in the blink/ directory and point "%s" to it.', + 'The blink binary for --blink was not found in "%s" env or on PATH. Build it with "go build" in the blink/ directory and point "%s" to it.', self::ENV_OVERRIDE, self::ENV_OVERRIDE, ));