Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 6, 2025

This PR consolidates version management by replacing hardcoded benchmarkVersion values with dynamic reading from the package.json version field, addressing the issue of having two sources of version information that could lead to inconsistencies.

Problem

The codebase had hardcoded benchmarkVersion: "1.0.0" values scattered across multiple files:

// In reporter.ts and leaderboard-generator.ts
metadata: {
    // ...
    benchmarkVersion: "1.0.0"  // Hardcoded!
}

This created maintenance issues:

  • Multiple places to update when bumping versions
  • Risk of missed updates leading to inconsistencies
  • Duplicate version management alongside package.json

Solution

Added version field to package.json:

{
  "name": "ts-bench",
  "version": "1.0.0",
  // ...
}

Created dynamic version utility:

// src/utils/package-version.ts
export async function getPackageVersion(): Promise<string> {
    // Reads from package.json with fallback to "1.0.0"
}

Replaced all hardcoded values:

  • BenchmarkReporter.generateBasicJSONData() now reads version dynamically
  • BenchmarkReporter.saveResult() now reads version dynamically
  • LeaderboardGenerator.generateLeaderboardData() now reads version dynamically

Benefits

Single source of truth - Version managed only in package.json
Automatic consistency - All benchmark outputs use the same version
Simplified maintenance - Version updates happen in one place
Backward compatibility - Existing data structures unchanged
Robust fallback - Graceful handling if package.json unavailable

The implementation includes multiple path resolution strategies and error handling to ensure reliability across different execution contexts.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] // Task: Unify benchmarkVersion with version // // Purpose: // Remove the custom field 'benchmarkVersion' used for schema identification, // and use the 'version' field from package.json as the schema version. // // Why: // - Having two sources of vers... Unify benchmarkVersion with package.json version field Sep 6, 2025
@Copilot Copilot AI requested a review from laiso September 6, 2025 11:40
Copilot finished work on behalf of laiso September 6, 2025 11:40
@laiso laiso marked this pull request as ready for review September 16, 2025 08:42
@laiso laiso merged commit ac4e5b2 into main Sep 16, 2025
1 check passed
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

const possiblePaths = [
join(currentDir, '../../package.json'), // From dist/utils/
join(currentDir, '../../../package.json'), // From src/utils/
join(process.cwd(), 'package.json') // From project root
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Path in getPackageVersion Function

The getPackageVersion function includes a path join(currentDir, '../../../package.json') that's intended for src/utils/. This path incorrectly navigates one directory above the project root, rather than to the project root. While other fallbacks prevent a functional issue, this path is logically incorrect.

Fix in Cursor Fix in Web

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