Skip to content

chore(scripts): extract shared utils, add tests, enforce standards#35

Merged
zrosenbauer merged 2 commits intomainfrom
chore/extract-shared-utils-add-tests
Mar 11, 2026
Merged

chore(scripts): extract shared utils, add tests, enforce standards#35
zrosenbauer merged 2 commits intomainfrom
chore/extract-shared-utils-add-tests

Conversation

@zrosenbauer
Copy link
Copy Markdown
Member

Summary

  • Extract shared utilities into scripts/lib/ (frontmatter, config, status, ansi, diff) eliminating ~100 lines of duplication across the three .lauf.ts scripts
  • Add vitest test infrastructure with 66 tests across 9 test files covering all pure functions
  • Remove optional chaining (?.), ternaries, and for loops from pure logic by extracting helper functions
  • Replace local utility copies with shared lib imports in all three .lauf.ts scripts
  • Replace inline ANSI colors and manual diff rendering with shared ANSI constant and displayDiff function
  • Add Result tuple error handling for readProjectConfig call sites

Changes

Phase 1: Test Infrastructure

  • Added vitest devDependency and test script to package.json
  • Created scripts/vitest.config.ts

Phase 2: Shared Utility Extraction

  • scripts/lib/frontmatter.tsparseFrontmatter, updateFrontmatter, extractTitle, FRONTMATTER_RE
  • scripts/lib/config.tsreadProjectConfig (Result tuple), FEATURES_DIR, config types
  • scripts/lib/status.tsreverseStatusMapping
  • scripts/lib/ansi.ts — consolidated ANSI escape codes
  • Fixed backup.ts dynamic imports and product-area-colors.ts duplicate key

Phase 3: Tests (66 total)

  • frontmatter.test.ts (10), config.test.ts (3), status.test.ts (3), diff.test.ts (3)
  • product-area-colors.test.ts (4), query-loader.test.ts (2)
  • features.test.ts (5), project.test.ts (17), readme.test.ts (19)

Phase 4: Standards Compliance

  • Replaced all ?. with explicit null checks
  • Replaced all ternaries with helper functions (resolveVisibility, formatStatusLabel, conditionalValue, etc.)
  • Converted Map-building for loops to new Map(items.filter.map) pattern
  • ~30 helper functions extracted across the three scripts

Shared Lib Integration

  • All three .lauf.ts files now import from shared libs instead of local copies
  • Removed yaml import from features.lauf.ts and readme.lauf.ts
  • Removed local ProjectConfig, FeaturesConfig, ConfigField, ConfigView type definitions
  • Replaced inline diff display in project.lauf.ts with displayDiff

Test plan

  • pnpm test — 66/66 tests pass
  • pnpm lint — 0 warnings, 0 errors
  • pnpm format:check — all files formatted
  • npx tsc -p scripts/tsconfig.json --noEmit — 0 TypeScript errors
  • Pre-commit hooks pass (lint, format, commitlint)

- Extract shared utilities into scripts/lib/ (frontmatter, config,
  status, ansi, diff) eliminating ~100 lines of duplication across
  the three .lauf.ts scripts
- Add vitest test infrastructure with 66 tests across 9 test files
- Remove optional chaining, ternaries, and for loops from pure logic
  by extracting helper functions
- Replace local utility copies with shared lib imports in all three
  .lauf.ts scripts
- Replace inline ANSI colors and diff rendering with shared constants
  and displayDiff function
- Add Result tuple error handling for readProjectConfig call sites

Co-Authored-By: Claude <noreply@anthropic.com>
…and tests

Fix unsafe parseYaml cast in frontmatter.ts, resolveDirection cancelled-by-value
bug in project.lauf.ts, and status badge mismatches in roadmap docs. Consolidate
duplicate ANSI codes and extractErrorMessage patterns into shared modules, replace
optional chaining and mutable array patterns in github-client.ts, and improve test
quality with consistent naming and explicit assertions.

Co-Authored-By: Claude <noreply@anthropic.com>
@zrosenbauer zrosenbauer merged commit ec65fd2 into main Mar 11, 2026
1 check passed
@zrosenbauer zrosenbauer deleted the chore/extract-shared-utils-add-tests branch March 11, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant