Repository navigation
refactor: split build_command.rb into cli/build modules (WP-00 R1) - #75
Merged
Merged
Conversation
Record every method BuildCommand defines (visibility and parameters), every constant it exposes (value digest) and where the source-checkout ruby_runtime resolves, so moving the implementation into cli/build/ cannot drop or reshape anything the tests, the Rails tasks or the other commands reach through it.
Move the 3.7k-line BuildCommand into one module per concern under cli/build/ (config_loader, client_dir, flutter_tooling, exports, pipeline, embedded_project, embedded_runtime, native_config/*, contributors/*). BuildCommand includes them all, so Ruflet::CLI, the Rails tasks and every includer resolve the same methods and constants. Every method and constant is moved verbatim, with its comments; 192 of 193 have an identical Prism AST. The exception is source_checkout_ruby_runtime_path, whose __dir__-relative path gains one "../" because its file is one directory deeper; it resolves to the same ruby_runtime checkout. .gitignore re-includes lib/ruflet/cli/build/, which **/build/ would otherwise hide.
prepare_flutter_client is to run the steps that write the client's configuration from a registered list: the built-ins in their current order, each taking one shared build context, the first refusal stopping the build before any tool runs, and a feature's own step placed with before:/after:.
prepare_flutter_client now runs the steps that write the client's configuration from Build::Contributors, an ordered list each contributor file adds itself to: template_refresh, apple_host, app_identity, protected_services, signing, runtime_mode, extensions, assets. Each takes one Build::Context and returns true to continue, exactly where the inline code continued, and the first refusal stops the build before any tool runs, as the early returns did. The Flutter steps after them are unchanged and read the metadata and asset flags from the context. A later feature adds its own step with Contributors.register, placed with before:/after:, instead of editing prepare_flutter_client.
The services contributor is to hand the Android permissions and macOS entitlements it wants to native_config writers that own those files: the managed set is replaced, everything else in the file is kept, and a second run changes nothing.
native_config/android_manifest gains write_android_manifest_permissions and the new native_config/entitlements owns write_macos_entitlements. The services contributor now only decides which permissions and entitlements it manages and wants, and hands them to those writers. The writers are the former loop bodies, unchanged, so the manifest and both entitlement files come out byte-identical (H1 goldens).
The registry is to list every ruflet.yaml and services.yaml key Ruflet reads, for `ruflet check` (CLI-22) to validate against later. A probe records every key the build's readers ask a config for; each of those, every key `ruflet new` and the Rails installer write, and every key the H1 fixtures use must be registered.
Build::ConfigSchema lists every ruflet.yaml and services.yaml key Ruflet reads: its dotted path, type (map, list, string, boolean, integer, path, url), the feature that reads it and a short description. Each feature declares its keys in config_schema/<feature>.rb (sections, app_identity, backend, signing, runtime, services, extensions, assets: 599 ruflet.yaml and 22 services.yaml keys); platform keys are registered in all three spellings platform_build_config merges. Nothing reads the registry yet, so no build changes. It is the list `ruflet check` (CLI-22) will validate projects against, and new ruflet.yaml keys register themselves in it (X4).
This was referenced Nov 8, 2026
Merged
…e schema files Two contributor behaviors no golden sees: a missing template root lets the build continue, and the extensions step records @ruflet_self_contained_build. Each config_schema file must load on its own; today only sections.rb-first load order works.
…eam_id's macOS use Every config_schema/<feature>.rb now requires sections (and sections the registry), so a WP-01 schema file can be required anywhere. The ios.team_id description says what the build does today: a macOS build writes it into the iOS Xcode project too. The registry is not read by any build yet.
--disable-gems broke the check wherever RUBYOPT activates a gem (a local Ruby 3.4.5 pinning minitest 5 does). The file needs no gems either way.
This was referenced Nov 18, 2026
AdamMusa
added a commit
that referenced
this pull request
Nov 20, 2026
#75 split build_command.rb into cli/build/ modules and turned prepare_flutter_client's steps into registered contributors. The seam is carried into that layout: - build_command.rb requires client_bootstrap and includes ClientBootstrap next to FlutterSdk, as before. - The write_client_bootstrap call, which ran right after the extension selection was applied and verified, is now the startup_hooks contributor (cli/build/contributors/startup_hooks.rb), registered after :extensions, so it still runs at that point, before assets and before Flutter. - build_contributors_test pins startup_hooks in that place in BUILT_IN and checks that the contributor passes the build on and always continues.
AdamMusa
added a commit
that referenced
this pull request
Nov 21, 2026
Port the build fixes onto the cli/build/* split (#75) and keep #77/#78's command registry: usage errors stay main's (exit 64), and the dispatcher, help heredoc and new-command checks this branch had are dropped in favour of main's. appbundle now gets aab's identity check, package rename and stale-output clearing without being renamed to aab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WP-00 R1.
build_command.rb(3,690 lines) is split into modules undercli/build/, with no behavior change. This branch now contains currentmain(#67 and the final #73, 234 goldens), merged in 58a564a.mainhad not changed any CLI code since the old base, so the merge had no conflicts.What
build_command.rbkeeps the requires,command_buildandcommand_install. The rest moves undercli/build/: loaders and helpers, thenative_config/writers andcontributors/.BuildCommandincludes these modules afterFlutterSdk, soRuflet::CLI, its includers and the Rails tasks see the same methods, visibility and constants.prepare_flutter_clientruns theBuild::Contributorslist in the old order: template_refresh → apple_host → app_identity → protected_services → signing → runtime_mode → extensions → assets. A later feature adds its step withregister(name, handler, before:/after:).Build::ConfigSchemaregisters 599 ruflet.yaml keys and 22 services.yaml keys. Nothing reads it yet; it is there for CLI-22.CLIENT_EXTENSION_MAPis still a literal. Making it data-driven is SVC-02.Behavior changes
None.
.gitignorere-includespackages/ruflet/lib/ruflet/cli/build/, which**/build/would otherwise hide.Changes in this round (after the Nov 8 approval)
origin/mainmerged in.config_schema/*.rbfile requires what it needs, so it can be loaded in any order. A test loads each file in its own process.ios.team_iddescription now says what the build does:build macosalso writes the team into the iOS Xcode project.template_refreshlets the build continue, andextensionssets@ruflet_self_contained_build.Proof (head
1b39384f)H1 goldens.
ruby test/compat/compat.rb --jobs 8printschecked 234 goldensand exits 0 on Ruby 4.0.5 and 3.4.5.compat_goldens_test.rbruns 242 tests with 0 failures.Suites. Each test file runs in its own process with the in-tree RUBYLIB, on Ruby 4.0.5 and on 3.4.5 (minitest 5, as in CI). All are green:
RUFLET_ENGINE_ROOT)Compared with
mainat c2d547b (Ruby 4.0.5), every file both trees share has the same runs and assertions. The extra 26 runs come from the 4 newbuild_*_test.rbfiles.Re-planted bugs. Each bug was planted alone in a copy of this head, then the full compat check and the 4 build tests were run:
build_contributors_testbuild_native_config_testbuild_native_config_testapple_plist.rbbuild_contributors_test(no golden)@ruflet_self_contained_buildbuild_contributors_test(no golden)build_contributors_test(no golden)ruby_runtimepath one../shortbuild_command_surface_testconfig_schemafile without its requirebuild_config_schema_testRows 1 to 7 come from the Nov 8 review; rows 8 and 9 are new.
Carried over from the Nov 8 review at 13eaf59, still valid because
git diff 13eaf591 HEAD -- packages/ruflet/libtouches onlyconfig_schema/: the Prism AST check (189 of 193 members identical, the 4 differences intended), constant resolution, and the doc harness (183 of 183).CI: every check passed on 1b39384: Verify Ruflet Explorer, including Run framework tests on Ruby 3.4.5 (run 44215502829); the Android, iOS Simulator, macOS, Windows, Linux and web prebuilds; and the Explorer desktop builds (runs 44215503234 and 44215495399). No job was re-run.
Other open PRs
build_command.rb. Whichever lands second moves its hunks into the split modules:command_buildstays inbuild_command.rb.install_platform_for_device→build/exports.rb.ruflet_config_path/load_ruflet_config→build/config_loader.rb, withapply_build_configinbuild/contributors/assets.rb. The signingreturn false→build/contributors/signing.rbandbuild/native_config/gradle.rb.configure_platform_autostart→build/contributors/runtime_mode.rb.write_client_bootstrapbecomes a contributor registeredafter: :extensions.