refactor(scripts): extract shared bash utilities to scripts/lib#88
Merged
PAMulligan merged 1 commit intoMay 22, 2026
Merged
Conversation
Consolidates duplicated patterns across shell scripts into three shared libraries: - scripts/lib/common.sh — banner/step/pass/fail/skip/warn output helpers, require_cmd/have_cmd, tracked tempfiles with auto EXIT trap, cross-platform now_ms, csv_contains, build_artifact_exists, project_root resolver, and a config_get wrapper that delegates to pipeline-config.js. - scripts/lib/colors.sh — ANSI color constants honoring NO_COLOR and TTY detection. - scripts/lib/pipeline-config.js — ESM module + CLI for reading .claude/pipeline.config.json (mtime-cached, boolean/object-aware shell rendering, prints fallback on any error so set -e callers stay safe). Migrated 9 high-duplication scripts to source the libs: check-security.sh (eliminated 3 inline node -e config reads + manual TMPFILES cleanup), check-dead-code.sh, check-types.sh, check-dark-mode.sh, check-responsive.sh, capture-baselines.sh, regression-test.sh, verify-all.sh (extracted csv_contains/now_ms/build_artifact_exists), and incremental-build.sh (moved ANSI color block to colors.sh). Net -106 lines across the 9 migrated scripts. Output format preserved exactly so existing script tests (verify-all, check-security, check-dead-code, check-responsive) continue to pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #51.
Summary
scripts/lib/common.sh(banner/step output helpers,require_cmd, tracked tempfiles with auto EXIT trap, cross-platformnow_ms,csv_contains,build_artifact_exists,common_config_getshell wrapper).scripts/lib/colors.sh(ANSI constants honoringNO_COLOR+ TTY detection).scripts/lib/pipeline-config.js(ESM module + CLI for reading.claude/pipeline.config.json; mtime-cached, boolean/object-aware shell rendering, prints fallback on any error soset -ecallers don't break).Migrated scripts
check-security.shnode -econfig reads + manualTMPFILEScleanupcheck-dead-code.shcheck-types.shcheck-dark-mode.shnode -econfig reads collapsedcheck-responsive.shcapture-baselines.shnode -econfig reads collapsedregression-test.shnode -econfig reads collapsedverify-all.shcsv_contains,now_ms,build_artifact_existsto libincremental-build.shcolors.shScope notes
incremental-build.sh) —colors.shexists for future adopters and now centralizes that one block.Test plan
vitest run scripts/__tests__/verify-all.test.js— 13/13 passvitest run scripts/__tests__/check-security.test.js— 4/4 passvitest run scripts/__tests__/check-dead-code.test.js— 4/4 passvitest run scripts/__tests__/check-responsive.test.js— 3/3 passbash -nsyntax check on every migrated scriptcommon_config_get,common_track_tmpfile,common_now_ms,common_csv_containsinteractivelyvitest run scripts/__tests__/clean — one pre-existingknip60s timeout flakes under concurrent disk load; passes in isolation🤖 Generated with Claude Code