Skip to content

Commit 203f0ca

Browse files
committed
Move the Gherkin linter pin into package.json
Drops the WP_CLI_TEST_GHERKIN_LINT_VERSION override, which was configuration nobody asked for, and puts the pinned version somewhere a dependency bot can see it. A version string inside a shell script is invisible to Dependabot; a devDependency in package.json is not. The package.json exists only to hold that pin: it is private, has no scripts, and nothing runs `npm install` against it. The runner reads the version out of it and fails loudly if it is missing, rather than quietly falling through to whatever the latest release happens to be. Note that picking these updates up needs an npm entry in the dependabot.yml that wp-cli/.github syncs out. Refs wp-cli/wp-cli#6161 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VcGmbu6CYzGGhP3jXuWDkJ
1 parent 1d6afbc commit 203f0ca

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎.readme-partials/USING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ different rules can override it by committing its own `.gherkin-lintrc`.
129129

130130
The linter is a Node package, so it is run through `npx` and needs Node.js 20 or
131131
later. Where `npx` is not available the check reports that it is skipping, rather
132-
than failing a suite that is otherwise entirely PHP. Pin a different release of
133-
the linter with `WP_CLI_TEST_GHERKIN_LINT_VERSION`.
132+
than failing a suite that is otherwise entirely PHP. Its version is pinned in
133+
this package's `package.json`, which exists only to hold that pin.
134134
135135
### Controlling the amount of output
136136

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ different rules can override it by committing its own `.gherkin-lintrc`.
140140

141141
The linter is a Node package, so it is run through `npx` and needs Node.js 20 or
142142
later. Where `npx` is not available the check reports that it is skipping, rather
143-
than failing a suite that is otherwise entirely PHP. Pin a different release of
144-
the linter with `WP_CLI_TEST_GHERKIN_LINT_VERSION`.
143+
than failing a suite that is otherwise entirely PHP. Its version is pinned in
144+
this package's `package.json`, which exists only to hold that pin.
145145
146146
### Controlling the amount of output
147147

‎bin/run-gherkin-lint-tests‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ then
4242
CONFIG_FILE="${WP_CLI_TESTS_ROOT}/.gherkin-lintrc"
4343
fi
4444

45-
# Pinned so that a new release of the linter cannot turn a green build red
46-
# without a commit in this repository.
47-
GHERKIN_LINT_VERSION="${WP_CLI_TEST_GHERKIN_LINT_VERSION:-1.0.2}"
45+
# The linter is pinned so that one of its releases cannot turn a green build red
46+
# without a commit here. The pin lives in package.json rather than in this file,
47+
# because a version string inside a shell script is invisible to Dependabot.
48+
PACKAGE_JSON="${WP_CLI_TESTS_ROOT}/package.json"
49+
GHERKIN_LINT_VERSION=$( php -r '$package = json_decode( (string) file_get_contents( $argv[1] ), true ); echo isset( $package["devDependencies"]["gherkin-lint-plus"] ) ? $package["devDependencies"]["gherkin-lint-plus"] : "";' "${PACKAGE_JSON}" 2> /dev/null )
50+
51+
if [ -z "${GHERKIN_LINT_VERSION}" ]
52+
then
53+
echo "Could not read the pinned gherkin-lint-plus version from ${PACKAGE_JSON}."
54+
exit 1;
55+
fi
4856

4957
# Without an explicit path the linter walks the whole working directory, vendor
5058
# included. The feature files are the target.

‎package.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "wp-cli-tests",
3+
"description": "Pins the Node tooling used by the WP-CLI testing framework. Not published to npm.",
4+
"private": true,
5+
"license": "MIT",
6+
"devDependencies": {
7+
"gherkin-lint-plus": "1.0.2"
8+
}
9+
}

0 commit comments

Comments
 (0)