Skip to content

Phase 3: code cleanup — remove dev page, split trail data#85

Merged
kwiens merged 5 commits into
mainfrom
oss-phase3-cleanup
Jun 21, 2026
Merged

Phase 3: code cleanup — remove dev page, split trail data#85
kwiens merged 5 commits into
mainfrom
oss-phase3-cleanup

Conversation

@kwiens

@kwiens kwiens commented May 20, 2026

Copy link
Copy Markdown
Owner

Third phase of the open-sourcing cleanup. Stacked on #84 (base oss-phase2-docs) — merge #83#84 → this in order.

Changes

Remove dev-only test page

src/app/test/page.tsx was a dev-only ride-recording harness. Removing it orphaned its two exclusive dependencies — src/data/example-tracks.ts (demo GPS fixtures) and src/utils/gpx-parser.ts (GPX import) — neither referenced or tested anywhere else. All three removed. GPX import was only ever reachable through that dev page; the shipped feature is GPX export. README corrected (GPX import/exportGPX export).

Split the trail data file

mountain-bike-trails.ts was 3,261 lines — ~3,000 of them a single array literal burying the interfaces and region logic. The array (and the trailColor helper only it uses) moves to a new mountain-bike-trails.data.ts; the original keeps the interfaces, layer-id constants, REGION_MAP, regionFor, and re-exports the array. The data file's only import from the logic file is the MountainBikeTrail type (erased at compile time) — no runtime circular dependency. Consumers importing from @/data/geo_data are unaffected; 224 trails, count unchanged.

Trail scripts updated to match:

  • Both point at mountain-bike-trails.data.ts (add_trail_bounds.py was also pointing at the wrong file — geo_data.ts — which never held the array).
  • add_trail_elevation.py now reads the Mapbox token from NEXT_PUBLIC_MAPBOX_TOKEN (env or .env.local) — Phase 1 moved the token out of map.config.ts, which had silently broken the script's regex extraction.

docs/DATA.md updated to point curators at the data file.

Deferred — Map.tsx decomposition

The plan's Map.tsx GPS/compass decomposition (and the Map.test.tsx event-wiring tests) are deferred to a separate PR. That subsystem can't be verified headlessly (no GPS/compass), and the event-wiring tests are only worth writing once the logic is extracted into independently testable hooks — so decomposition + tests belong together, in a PR that can be device-tested.

Test plan

  • pnpm test:run — 327 pass
  • pnpm lint — passes (8 pre-existing warnings)
  • pnpm build — passes; /test route gone
  • Browser: MTB trails still render after the split (27 features in the Raccoon Mountain area, real trail names)

@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bikemap Ready Ready Preview Jun 21, 2026 3:58am

Request Review

kwiens added 3 commits June 20, 2026 20:55
src/app/test/page.tsx was a dev-only ride-recording harness. Removing it
orphans its two exclusive dependencies — src/data/example-tracks.ts (demo
GPS fixtures) and src/utils/gpx-parser.ts (GPX import) — neither of which
is referenced or tested anywhere else.

GPX import was only ever reachable through that dev page; the shipped
feature is GPX export. README updated accordingly.
mountain-bike-trails.ts was 3,261 lines — ~3,000 of them a single array
literal that buried the interfaces and region logic. Move the array (and
the trailColor helper that only the array uses) into a new
mountain-bike-trails.data.ts; the original keeps the MountainBikeTrail /
ElevationProfile interfaces, layer-id constants, REGION_MAP, and regionFor,
and re-exports the array. The data file's only import from the logic file
is the MountainBikeTrail type, which is erased at compile time — no runtime
circular dependency. Consumers importing from @/data/geo_data are
unaffected.

Update the trail scripts to match:
- Both point at mountain-bike-trails.data.ts (add_trail_bounds.py was also
  pointing at the wrong file, geo_data.ts, which never held the array).
- add_trail_elevation.py reads the Mapbox token from NEXT_PUBLIC_MAPBOX_TOKEN
  (env or .env.local) — Phase 1 moved the token out of map.config.ts, which
  had broken the script's regex-based extraction.

docs/DATA.md updated to point curators at the data file.
The interface comment listed only "easy" | "intermediate" | "" but the
data and trailColor() also use "advanced" and "expert". Flagged during the
Phase 2 doc review as a Phase 3 cleanup item.
@kwiens
kwiens force-pushed the oss-phase3-cleanup branch from 2e0aeb2 to af3d2ee Compare June 21, 2026 03:55
@kwiens
kwiens changed the base branch from oss-phase2-docs to main June 21, 2026 03:55
The data file has 224 trails; '220+' matches CLAUDE.md phrasing and won't
drift as trails are added or removed.
Phase 3 moved the editable mountainBikeTrails array (and trailColor) to
src/data/mountain-bike-trails.data.ts. Point the elevation-script output
and the 'add a trail' steps at the data file. The MTN_BIKE_* constants and
REGION_MAP stayed in the wrapper mountain-bike-trails.ts, so those refs are
unchanged.
@kwiens
kwiens merged commit 934e8e9 into main Jun 21, 2026
3 checks passed
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.

1 participant