Skip to content

Conversation

flenter
Copy link
Member

@flenter flenter commented Oct 17, 2025

Summary

Fixes the failing CLI build by ensuring the web package is built before the CLI, and simplifies the build system with a unified build command.

Changes

1. Fix build order in root package.json

  • Root bun run build now builds all packages in dependency order: types → core → api → server → web → cli
  • Previously only built web and cli, causing library packages to be missing
  • Ensures web package's dist files exist before CLI's postbuild script tries to copy them

2. Fix release workflow

  • Added API package build (was missing from build-libs job)
  • Added web package build before CLI build
  • Merged separate build-libs and build-cli jobs into single unified "Build packages" job
  • Now uses root bun run build command for consistency

3. Simplify CI workflow

  • Replaced individual bun run --filter <package> build commands with single bun run build command
  • Single source of truth for build order
  • Less duplication, easier to maintain

Build Order

All workflows now follow the same dependency order:

  1. types (no dependencies)
  2. core (depends on types)
  3. api (depends on core, types)
  4. server (depends on core)
  5. web (depends on api)
  6. cli (depends on all)

Fixes

Resolves the issue where CLI build fails with:

cp: cannot stat '../web/dist/*': No such file or directory

This happened because the web package wasn't built before the CLI's postbuild script tried to copy the dist files.

Copy link

changeset-bot bot commented Oct 17, 2025

⚠️ No Changeset found

Latest commit: ed1f04a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@flenter flenter force-pushed the fix/build-order-and-simplify branch 2 times, most recently from 67b5b5a to 26fa059 Compare October 17, 2025 17:14
@laulauland
Copy link
Member

can you add the @fiberplane/mcp-gateway-api to ignored packages in the .changeset/config.json?

@flenter
Copy link
Member Author

flenter commented Oct 17, 2025

Done

*/
function getMigrationsFolder(): string {
// Try binary location first (next to executable)
const binaryDrizzleDir = join(process.execPath, "..", "drizzle");
Copy link
Collaborator

Choose a reason for hiding this comment

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

binary???

Copy link
Member Author

@flenter flenter Oct 21, 2025

Choose a reason for hiding this comment

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

Yes, this comment isn't super clear but the CLI is executed as a (bun build) binary.

Looking at it again, i don't really like this logic. So I have changed it (the code now tries to figure out whether it's running as part of a bun built binary)

The CLI package's postbuild script copies the web UI dist files to the public folder.
However, the web package wasn't being built before the CLI, causing the build to fail
with "No such file or directory" when trying to copy ../web/dist/*.

Fixed by updating the root build script to build the web package first, then the CLI package.
The release workflow was missing builds for:
1. Web package - needed by CLI's postbuild script to copy dist files
2. API package - a dependency of the CLI

Added both builds in correct dependency order to match the CI workflow,
ensuring all dependencies are available when the CLI is built.
Updated the root build command to build all packages in the correct
dependency order: types → core → api → server → web → cli

This ensures:
1. Developers running 'bun run build' get a complete build
2. All packages are built in dependency order
3. Consistent behavior across local development, CI, and release workflows

Build order follows the documented package dependency graph where each
package builds after its dependencies are ready.
Both CI and release workflows now use the comprehensive 'bun run build'
command instead of duplicating individual package build commands.

Benefits:
1. Single source of truth for build order (package.json)
2. Less duplication and easier to maintain
3. If build order needs to change, update it in one place
4. Simpler, more readable workflow files

Build order remains: types → core → api → server → web → cli
The build-binaries job does a fresh checkout, so the web dist files
won't be available. We need to run 'bun run build' in each build-binaries
job to ensure all packages (including web) are built before the binary
is compiled.

Without this, the CLI's public folder won't have the web UI files when
the binary is being compiled.
The binary looks for a 'public' folder next to the executable at runtime
to serve the web UI. This change copies the public folder from the CLI
package to each binary package after compilation.

Also updates the package.json files array to include 'public' so it gets
published to npm alongside the binary.
Changed from 'bun run build' (which builds all 6 packages) to only building
web and CLI packages before compiling binaries. This is more efficient since:

1. Library packages (types, core, api, server) were already built and validated in build-libs job
2. Binary compilation only needs web dist files (copied to CLI's public folder)
3. Reduces redundant work in the matrix build job

Before: Build all 6 packages on each platform
After: Build only 2 packages (web + CLI) on each platform
…loader

The SQLite backend needs the drizzle migrations folder at runtime to initialize
the database. This change:

1. Copies packages/core/drizzle to binary packages after compilation
2. Updates getMigrationsFolder() to check for migrations next to the executable
   before falling back to the development location
3. Includes 'drizzle' in the binary package.json files array for npm publishing

This fixes the "Can't find meta/_journal.json file" error that prevented
the SQLite backend from initializing, which caused API responses to be empty.
…d drizzle folders

For consistency with the build-binaries.ts script which automatically
creates package.json files with these folders in the files array.
- Gitignore public/ and drizzle/ folders in platform packages since they're
  auto-generated by build-binaries.ts script
- Update darwin-arm64 package.json to include public and drizzle in files array
@flenter flenter force-pushed the fix/build-order-and-simplify branch from 0b16943 to ed1f04a Compare October 21, 2025 11:59
@flenter flenter merged commit 26b8c1c into main Oct 21, 2025
1 check passed
@flenter flenter deleted the fix/build-order-and-simplify branch October 21, 2025 12:02
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.

3 participants