From b187e2e1bd1e5d4c1714c736271f5be171e3d6f8 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Tue, 20 Oct 2026 21:23:03 -0400 Subject: [PATCH] fix(stellar-scaffold-cli): expose `build --compile-only` flag Officially encouraged Stellar Scaffold deploy process: 1. Build Wasm binaries for testnet 2. Publish & deploy them with Stellar Registry CLI 3. Update `testnet` sections of `scaffold.yml` to point at deployed instances (using contract IDs or Registry names) By default, version 2 builds also deploy contracts and generate clients. That prevents compiling Wasm independently when testnet client generation depends on contracts that have not been deployed yet. Expose the existing --compile-only flag so users can build Wasm before publishing and deploying it through Stellar Registry CLI, without triggering Scaffold deployment or client generation. --compile-only still validates scaffold.yml, including settings for all declared networks. Contract IDs and Registry names must be syntactically valid, but their referenced contracts need not exist yet: this build skips the deployment/client-generation steps that would attempt to use them. --- .../src/commands/build/mod.rs | 44 ++++++++++++++----- .../stellar-scaffold-cli/src/commands/mod.rs | 2 +- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/crates/stellar-scaffold-cli/src/commands/build/mod.rs b/crates/stellar-scaffold-cli/src/commands/build/mod.rs index 0e7e849f..919d2fd5 100644 --- a/crates/stellar-scaffold-cli/src/commands/build/mod.rs +++ b/crates/stellar-scaffold-cli/src/commands/build/mod.rs @@ -33,20 +33,17 @@ pub struct Command { /// List package names in order of build #[arg(long, visible_alias = "ls")] pub list: bool, - #[command(flatten)] - pub build: build::Cmd, - /// Also deploy contracts and generate their clients. Only needed for - /// projects on environments.toml; with a version 2 scaffold.yml this - /// always happens, as configured there. + /// Only compile Wasm binaries; skip client generation even for a version 2 project + #[arg(long)] + pub compile_only: bool, + /// Deprecated for version 2 projects with scaffold.yml: clients are generated by default. + /// Use --compile-only to skip deployment and client generation. #[arg(long)] pub build_clients: bool, #[command(flatten)] pub build_clients_args: clients::ClientsArgs, - /// Only compile, skipping deploys and client generation even for a - /// version 2 project. Set by commands that build as one step of their own - /// work; users get compile-only from `stellar contract build`. - #[arg(skip)] - pub compile_only: bool, + #[command(flatten)] + pub build: build::Cmd, } #[derive(thiserror::Error, Debug)] @@ -244,7 +241,7 @@ impl Command { let is_v2 = v2::is_v2(workspace_root); if self.build_clients && is_v2 { printer.infoln( - "--build-clients is no longer needed: with a version 2 scaffold.yml, build always deploys and generates clients as configured there", + "--build-clients is no longer needed: with a version 2 scaffold.yml, build generates clients by default. Skip with --compile-only", ); } builds_clients(self.compile_only, self.build_clients, is_v2) @@ -524,6 +521,31 @@ fn builds_clients(compile_only: bool, flag: bool, is_v2: bool) -> bool { #[cfg(test)] mod tests { use super::builds_clients; + use crate::commands::{Cmd, Root}; + use clap::Parser; + + #[test] + fn compile_only_is_a_public_build_flag() { + for (args, expected) in [ + (vec!["stellar-scaffold", "build"], false), + (vec!["stellar-scaffold", "build", "--compile-only"], true), + ( + vec![ + "stellar-scaffold", + "build", + "--compile-only", + "--build-clients", + ], + true, + ), + ] { + let root = Root::try_parse_from(args).unwrap(); + let Cmd::Build(command) = root.cmd else { + panic!("expected build command"); + }; + assert_eq!(command.compile_only, expected); + } + } #[test] fn v2_builds_clients_without_the_flag() { diff --git a/crates/stellar-scaffold-cli/src/commands/mod.rs b/crates/stellar-scaffold-cli/src/commands/mod.rs index 671973cd..e1dbe7b0 100644 --- a/crates/stellar-scaffold-cli/src/commands/mod.rs +++ b/crates/stellar-scaffold-cli/src/commands/mod.rs @@ -93,7 +93,7 @@ pub enum Cmd { /// Version of the scaffold-stellar-cli Version(version::Cmd), - /// Build contracts, resolving dependencies in the correct order. If you have an `environments.toml` file, it will also follow its instructions to configure the environment set by the `STELLAR_SCAFFOLD_ENV` environment variable, turning your contracts into frontend packages (JS dependencies). + /// Build contracts, resolving dependencies in the correct order; build clients (JS packages) as specified in `scaffold.yml` Build(build::Command), /// generate contracts