Use runtime project config in build, export, and simulate flows#3157
Conversation
There was a problem hiding this comment.
💡 Codex Review
Line 363 in 7dbe3c7
When tscircuit.config.ts supplies a runtime platformConfig with function-valued maps such as footprintLibraryMap (the new tests use exactly this shape), tsci build --concurrency 2 routes buildOptions through worker.postMessage in buildFilesWithWorkerPool. Worker messages are structured-cloned, so those functions cannot be cloned and the build fails before any worker can use the config; this affects any parallel build that relies on runtime platform config.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, | ||
| ) => { | ||
| const formatOption = options.format ?? "json" | ||
| const projectConfig = await loadRuntimeProjectConfig(process.cwd()) |
There was a problem hiding this comment.
Resolve export config from the input file
Loading runtime config from process.cwd() means tsci export /path/to/project/index.circuit.tsx ignores /path/to/project/tscircuit.config.ts whenever the command is invoked from another directory, even though the file argument and output location are already based on that project path. In that scenario custom footprints/platform settings silently disappear; resolve the project dir from file as the build flow does before loading the config.
Useful? React with 👍 / 👎.
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
Summary
This PR wires runtime project config into the actual CLI command flows for:
buildexportsimulateIt allows
tscircuit.config.ts/tscircuit.config.jsto affect these command paths after the loader foundation from the previous PR.Why
The previous PR added runtime project config loading,
.envhydration, and JSON + module config merging.That established the config loader foundation, but it did not yet make the actual CLI command handlers consume the new runtime config.
This PR is the next step: making the real command flows use the runtime config, especially
platformConfig, so custom project-level behavior can reach command execution.This follows the review direction to take the simplest path:
platformConfigWhat changed
Build command flow
Files:
cli/build/build-ci.tscli/build/get-build-entrypoints.tscli/build/register.tsChanges:
build --cinow reads runtime project config vialoadRuntimeProjectConfig(...)includeBoardFilespreviewComponentPathsiteDefaultComponentPathbuildnow merges:projectConfig.platformConfig--disable-pcb--routing-disabled--disable-parts-engineExport command flow
File:
cli/export/register.tsChanges:
exportnow loads runtime project configplatformConfigwith CLI disable-parts-engine overrideSimulate command flow
File:
cli/simulate/register.tsChanges:
simulate analognow loads runtime project configplatformConfigwith CLI disable-parts-engine overrideShared board-file discovery
File:
lib/shared/find-board-files.tsChanges:
findBoardFilesAsync(...)includeBoardFilesthroughtscircuit.config.ts/jsfindBoardFiles(...)path is preservedShared platform config merging
File:
lib/shared/platform-config-utils.tsChanges:
mergePlatformConfigs(...)PlatformConfigobjects without losing nested maps like:footprintLibraryMapfootprintFileParserMapstaticFileLoaderMapautorouterMapspiceEngineMapFiles changed
cli/build/build-ci.tscli/build/get-build-entrypoints.tscli/build/register.tscli/export/register.tscli/simulate/register.tslib/shared/find-board-files.tslib/shared/platform-config-utils.tstests/cli/runtime-project-config-command-flows.test.tsTests
Added focused runtime command-flow coverage for:
Test file:
tests/cli/runtime-project-config-command-flows.test.tsThese tests use
tscircuit.config.tswith a fake function-valuedplatformConfig.footprintLibraryMap.tiso the command paths exercise runtime project config, not just config parsing.Validation
Passed locally:
bun test tests/cli/runtime-project-config-command-flows.test.tsfor build-entrypoint coverageBlocked locally for full
export/simulatecommand validation by an existing repo/package issue:circuit-json-to-kicadpackage does not exportresolveAndLoadKicad3dModelFilesScope intentionally excluded
This PR does not include:
tsci devruntime config wiringkicadLibraryNameruntime-config supportThose can be handled in follow-up PRs.