Skip to content

Conversation

@vertti
Copy link
Owner

@vertti vertti commented Dec 30, 2025

Summary

Replaces two abandoned/stale dependencies with stdlib-based alternatives:

  • github.com/tidwall/gjson → Internal pkg/jsonpath package using encoding/json
  • github.com/jwalton/go-supportscolorgolang.org/x/term + explicit CI detection

Benefits

  • Smaller binary (removed 4 dependencies)
  • Better security (stdlib-based JSON handling)
  • Full control over CI color detection (GitHub Actions, GitLab CI, CircleCI, Travis, Jenkins, Azure Pipelines, Buildkite, TeamCity, Drone, Bitbucket, AWS CodeBuild, Woodpecker)
  • Added support for NO_COLOR and CLICOLOR_FORCE standards

Changes

  1. New pkg/jsonpath package (~100 lines) providing:

    • Valid(s string) bool - JSON validation
    • Get(json, path string) Result - dot-notation path queries
    • Support for nested keys and array indices (e.g., data.result.0.value.1)
  2. Updated checks to use jsonpath:

    • pkg/envcheck - JSON validation
    • pkg/jsoncheck - JSON validation and key lookups
    • pkg/httpcheck - JSON path queries in responses
    • pkg/promcheck - Prometheus API response parsing
  3. New color detection in pkg/output:

    • TTY detection via term.IsTerminal()
    • Automatic CI environment detection
    • PREFLIGHT_COLOR, NO_COLOR, CLICOLOR_FORCE support

Internal package to replace github.com/tidwall/gjson with stdlib-only
implementation. Supports dot-notation paths with array indices
(e.g., "data.result.0.value.1").
Replace gjson.Valid with jsonpath.Valid for JSON validation.
Replace gjson with jsonpath for JSON validation and key lookups.
Replace gjson with jsonpath for JSON path queries in HTTP responses.
Replace gjson with jsonpath for parsing Prometheus API responses.
Use golang.org/x/term for TTY detection and add explicit CI environment
detection for GitHub Actions, GitLab CI, CircleCI, Travis, Jenkins,
Azure Pipelines, Buildkite, TeamCity, Drone, Bitbucket, AWS CodeBuild,
and Woodpecker CI.

Also adds support for NO_COLOR and CLICOLOR_FORCE standards.
Removed:
- github.com/tidwall/gjson (and transitive deps match, pretty)
- github.com/jwalton/go-supportscolor

golang.org/x/term is now a direct dependency.
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 91.96429% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.99%. Comparing base (15666e1) to head (fbca3d9).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
pkg/jsonpath/jsonpath.go 90.00% 4 Missing and 2 partials ⚠️
pkg/output/output.go 92.30% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
+ Coverage   88.72%   88.99%   +0.26%     
==========================================
  Files          31       32       +1     
  Lines        1313     1408      +95     
==========================================
+ Hits         1165     1253      +88     
- Misses        108      113       +5     
- Partials       40       42       +2     
Files with missing lines Coverage Δ
pkg/envcheck/check.go 96.07% <100.00%> (ø)
pkg/httpcheck/check.go 89.34% <100.00%> (ø)
pkg/jsoncheck/check.go 91.42% <100.00%> (ø)
pkg/promcheck/check.go 87.80% <100.00%> (ø)
pkg/output/output.go 94.73% <92.30%> (+3.82%) ⬆️
pkg/jsonpath/jsonpath.go 90.00% <90.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Document all CI systems that are now auto-detected for color support
and add new environment variables (CLICOLOR_FORCE, PREFLIGHT_COLOR=0).
Release notes are tracked in GitHub Releases.
Test shouldEnableColor() and isCIEnvironment() to improve coverage.
@vertti vertti merged commit 7a7528f into main Dec 30, 2025
17 checks passed
@vertti vertti deleted the replace-abandoned-deps branch December 30, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants