Skip to content

Conversation

@Devesh36
Copy link

@Devesh36 Devesh36 commented Dec 3, 2025

Overview

Implement a postinstall script that automatically synchronizes package versions in @tscircuit/eval with the main @tscircuit/core repository, preventing version drift between the two packages.

Changes

  • New file: scripts/postinstall.ts - Postinstall script that:

    • Compares devDependencies and dependencies from both @tscircuit/eval and @tscircuit/core
    • Updates outdated package versions to match core
    • Validates that all core dependencies exist in eval (or are explicitly excluded)
    • Provides clear error messages when dependencies are missing
    • Logs successful synchronization status
  • Updated: package.json

    • Added "postinstall": "bun run scripts/postinstall.ts || true" to scripts section
    • Script runs automatically after bun install (or npm/yarn equivalents)

How It Works

  1. Loads package.json files from both @tscircuit/core and @tscircuit/eval
  2. Identifies version mismatches in common dependencies
  3. Updates eval's package.json with core versions using regex replacement
  4. Validates that no core dependencies are missing (with DO_NOT_SYNC_PACKAGE allowlist for exceptions)
  5. Reports changes or confirms all versions are in sync

Implementation Details

DO_NOT_SYNC_PACKAGE List

The following packages are excluded from synchronization (either eval-specific or not applicable):

  • @biomejs/biome - Eval-specific linting
  • @tscircuit/import-snippet - Eval-specific feature
  • @tscircuit/layout - Eval-specific feature
  • @tscircuit/log-soup - Eval-specific feature
  • @tscircuit/common - Eval-specific feature
  • @tscircuit/schematic-autolayout - Eval-specific feature
  • @types/* - Type definitions (managed separately)
  • tsup - Build tool (eval-specific)
  • react-reconciler, react-reconciler-18 - Eval-specific dependencies
  • bun-match-svg, chokidar-cli, pkg-pr-new, howfat, live-server, looks-same, ts-expect - Dev/test tools
  • concurrently, nanoid, eecircuit-engine - Eval-specific
  • @flatten-js/core, @lume/kiwi, calculate-packing, css-select, format-si-unit, performance-now, transformation-matrix - Core-only dependencies

Error Handling

  • Missing dependencies: Script validates all core dependencies exist in eval. If missing, it throws a clear error message suggesting to either add them to package.json or add them to the DO_NOT_SYNC_PACKAGE list.
  • File operations: Uses Bun's file APIs for safe package.json manipulation
  • Graceful exit: Script exits with code 1 on errors, preventing installation from failing with the || true fallback

Benefits

  • Automatic version synchronization - Runs on every bun install
  • Prevents version drift - Eval always matches core versions
  • Clear validation - Reports mismatches and missing dependencies
  • Zero-config - Works out of the box after install
  • Flexible exclusions - DO_NOT_SYNC_PACKAGE list for eval-specific packages
  • Clear error messages - Helpful guidance when issues are detected

Testing

Script has been tested and validates successfully:

✓ All dependencies are already in sync with core

Related Issue

Closes #357

Checklist

  • Postinstall script created and functional
  • Package.json updated with postinstall hook
  • Script tested and working
  • Error handling implemented
  • Clear success/error messages provided
  • DO_NOT_SYNC_PACKAGE list configured appropriately

/fix #357

@Devesh36 Devesh36 marked this pull request as draft December 3, 2025 13:26
@Devesh36 Devesh36 marked this pull request as ready for review December 4, 2025 03:21
Copy link

@rushabhcodes rushabhcodes left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@imrishabh18 imrishabh18 left a comment

Choose a reason for hiding this comment

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

This issue seems to be stale, not sure if this is needed anymore cause we have a workflow which auto-updates eval with the new version of core release.

RaghavArora14

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Dec 7, 2025

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@Devesh36 Devesh36 marked this pull request as draft December 7, 2025 06:02
@github-actions
Copy link

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

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.

Use post install script to version match with core

4 participants