From 94069f2733c525d5bf715c31273788a704666f59 Mon Sep 17 00:00:00 2001 From: Devesh36 <142524747+Devesh36@users.noreply.github.com> Date: Wed, 3 Dec 2025 18:18:25 +0530 Subject: [PATCH 1/3] feat: add postinstall script to synchronize core package versions --- package.json | 3 +- scripts/postinstall.ts | 123 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 scripts/postinstall.ts diff --git a/package.json b/package.json index ca2ba172..6007c2d5 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "@tscircuit/eval", "main": "dist/lib/index.js", - "version": "0.0.515", + "version": "0.0.516", "type": "module", "files": [ "dist" ], "scripts": { + "postinstall": "bun run scripts/postinstall.ts || true", "build": "bun run build:lib && bun run build:webworker && bun run build:blob-url && bun run build:runner && bun run build:worker-wrapper && bun run build:platform-config", "build:lib": "tsup-node --config tsup-lib.config.ts", "build:platform-config": "tsup-node --config tsup-platform-config.config.ts", diff --git a/scripts/postinstall.ts b/scripts/postinstall.ts new file mode 100644 index 00000000..0333410d --- /dev/null +++ b/scripts/postinstall.ts @@ -0,0 +1,123 @@ +/** + * Postinstall script to synchronize core-related package versions + * with the main tscircuit core repository. + * + * This script is run after dependencies are installed to ensure + * that tscircuit/eval always has matching versions with @tscircuit/core. + */ + +// @ts-ignore +import corePackageJson from "@tscircuit/core/package.json" +import currentPackageJson from "../package.json" + +const DO_NOT_SYNC_PACKAGE = [ + "@biomejs/biome", + "@tscircuit/import-snippet", + "@tscircuit/layout", + "@tscircuit/log-soup", + "@tscircuit/common", + "@tscircuit/schematic-autolayout", + "@types/*", + "tsup", + "react-reconciler", + "react-reconciler-18", + "bun-match-svg", + "chokidar-cli", + "pkg-pr-new", + "howfat", + "live-server", + "looks-same", + "ts-expect", + "concurrently", + "nanoid", + "eecircuit-engine", + "@flatten-js/core", + "@lume/kiwi", + "calculate-packing", + "css-select", + "format-si-unit", + "performance-now", + "transformation-matrix", +] + +try { + const coreDeps: any = { + ...corePackageJson.devDependencies, + ...corePackageJson.dependencies, + } + + const currentDeps: any = { + ...currentPackageJson.devDependencies, + ...(currentPackageJson as any).dependencies, + } + const depsToUpdate: any = {} + + let modifiedDeps = false + + // Update dependencies to match core + for (const [packageName, currentVersion] of Object.entries(currentDeps)) { + if (packageName in coreDeps && coreDeps[packageName] !== currentVersion) { + console.log( + `Updating ${packageName} from ${currentVersion} to ${coreDeps[packageName]}`, + ) + depsToUpdate[packageName] = coreDeps[packageName as keyof typeof coreDeps] + modifiedDeps = true + } + } + + // Check for missing core dependencies + const missingDeps: string[] = [] + for (const packageName of Object.keys(coreDeps)) { + if ( + DO_NOT_SYNC_PACKAGE.some((dnsp) => + dnsp.includes("*") + ? packageName.startsWith(dnsp.replace("*", "")) + : packageName === dnsp, + ) + ) { + continue + } + if (!(packageName in currentDeps)) { + missingDeps.push(packageName) + } + } + + if (missingDeps.length > 0) { + throw new Error( + `Missing core dependencies in package.json: ${missingDeps.join(", ")}. ` + + `\n\nAdd them to package.json or add to DO_NOT_SYNC_PACKAGE list.`, + ) + } + + if (modifiedDeps) { + // Use regex to replace the dependencies in the package.json + const packageJsonPath = new URL("../package.json", import.meta.url).pathname + // @ts-ignore Bun global + let packageJson = await Bun.file(packageJsonPath).text() + for (const [packageName, version] of Object.entries(depsToUpdate)) { + const pattern = `"${packageName}":\\s*"${currentDeps[packageName].replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}"(,)?` + packageJson = packageJson.replace( + new RegExp(pattern), + `"${packageName}": "${version}"$1`, + ) + } + // @ts-ignore Bun global + await Bun.write(packageJsonPath, packageJson) + console.log("✓ Core versions synchronized successfully") + } else { + console.log("✓ All dependencies are already in sync with core") + } +} catch (error) { + if (error instanceof Error) { + console.error(`✗ Failed to synchronize core versions: ${error.message}`) + if (error.message.includes("Cannot find module")) { + console.error( + "Error: @tscircuit/core package not found. Make sure dependencies are installed.", + ) + } + } else { + console.error("✗ An unexpected error occurred during postinstall") + } + // @ts-ignore process global + process.exit(1) +} From 44fd766ebc0272e56a09191e7a594541a23b953d Mon Sep 17 00:00:00 2001 From: Devesh36 <142524747+Devesh36@users.noreply.github.com> Date: Thu, 4 Dec 2025 08:54:33 +0530 Subject: [PATCH 2/3] chore: bump version to 0.0.519 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6007c2d5..e2452765 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@tscircuit/eval", "main": "dist/lib/index.js", - "version": "0.0.516", + "version": "0.0.519", "type": "module", "files": [ "dist" From aa1d684a29ec6896ab4cb423536563ddf43f72bb Mon Sep 17 00:00:00 2001 From: Devesh36 <142524747+Devesh36@users.noreply.github.com> Date: Thu, 4 Dec 2025 09:55:02 +0530 Subject: [PATCH 3/3] version to 0.0.520 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e2452765..8763aac0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@tscircuit/eval", "main": "dist/lib/index.js", - "version": "0.0.519", + "version": "0.0.520", "type": "module", "files": [ "dist"