From 0a1e04d3b74de1bdf0c5fdda90c6b1bef8ede58c Mon Sep 17 00:00:00 2001 From: Julien <120588494+julien4215@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:20:57 +0100 Subject: [PATCH] Fully remove flutter and mobile commands from lila-docker --- README.md | 60 -------------------------- command/src/main.rs | 102 -------------------------------------------- lila-docker | 17 -------- 3 files changed, 179 deletions(-) diff --git a/README.md b/README.md index f52dac93..4e52859a 100644 --- a/README.md +++ b/README.md @@ -203,19 +203,6 @@ docker compose run --rm -w /scalachess --entrypoint="sbt testKit/test" lila docker compose run --rm -w /scalachess --entrypoint="sbt package" lila ``` -### Dartchess: - -```bash -## run formatter -docker compose run --rm -w /dartchess mobile dart format . - -## analyze -docker compose run --rm -w /dartchess mobile bash -c "dart pub get && dart analyze" - -## run tests -docker compose run --rm -w /dartchess mobile bash -c "dart pub get && dart test -x full_perft" -``` - ### Developing Chessground or PGN-Viewer locally By default, your local lila instance will use the version of chessground + pgn-viewer that are published to npm. If you want to make changes to either library and see them reflected in your local lila instance, you can do the following: @@ -259,50 +246,3 @@ curl --get http://localhost:8086/query \ --data-urlencode "db=kamon" \ --data-urlencode "q=show measurements;" ``` - -### Mobile - -> [!IMPORTANT] -> Requires Flutter and `adb` to be installed locally. Verify Flutter is configured correctly with `flutter doctor`. - -1. On your Android phone: - 1. Connect your phone to the same wifi network as your host machine - 2. Enable Developer Mode - 3. In Developer Options, toggle Wireless Debugging to ON - 4. Tap "Wireless Debugging" to enter its menu -2. On your host machine: - - 1. Have the lila-docker services running, with the `Mobile` optional service started - 2. Configure lila to run with your host's IP address or hostname instead of localhost - - ```bash - ./lila-docker hostname - ``` - - - Then verify that your phone can access the site at `http://[your-selection]:8080` - - 3. Connect to your phone - - ```bash - ./lila-docker mobile - ``` - - 4. Verify your phone is listed - - ```bash - adb devices - ``` - - 5. Install the app dependencies and run the app: - - ```bash - cd repos/mobile - - flutter channel beta - flutter upgrade - - flutter pub get - dart run build_runner build - - flutter run - ``` diff --git a/command/src/main.rs b/command/src/main.rs index 488b9747..21cc94b6 100644 --- a/command/src/main.rs +++ b/command/src/main.rs @@ -38,10 +38,6 @@ struct Config { setup_api_tokens: Option, lila_domain: Option, lila_url: Option, - phone_ip: Option, - connection_port: Option, - pairing_code: Option, - pairing_port: Option, } macro_rules! to_env { @@ -89,10 +85,6 @@ impl Config { setup_api_tokens, lila_domain, lila_url, - phone_ip, - connection_port, - pairing_code, - pairing_port, } = self; let compose_profiles_string = compose_profiles .clone() @@ -111,10 +103,6 @@ impl Config { to_env!(setup_api_tokens), to_env!(lila_domain), to_env!(lila_url), - to_env!(phone_ip), - to_env!(connection_port), - to_env!(pairing_code), - to_env!(pairing_port), ] .iter() .filter(|line| !line.is_empty()) @@ -221,9 +209,7 @@ fn main() -> std::io::Result<()> { "setup" => setup(config, true, std::env::var("NONINTERACTIVE").is_ok()), "add_services" => setup(config, false, false), "hostname" => hostname(config), - "mobile" => mobile_setup(config), "welcome" => welcome(config), - "flutter" => flutter(config), "gitpod_public" => gitpod_public(), _ => panic!("Unknown command"), } @@ -407,8 +393,6 @@ fn create_placeholder_dirs() { Repository::new("lichess-org", "chessground"), Repository::new("lichess-org", "pgn-viewer"), Repository::new("lichess-org", "scalachess"), - Repository::new("lichess-org", "mobile"), - Repository::new("lichess-org", "dartchess"), Repository::new("lichess-org", "berserk"), Repository::new("cyanfish", "bbpPairings"), ] @@ -588,22 +572,6 @@ fn prompt_for_services() -> Result>, Error> { "Scalachess", "standalone chess logic library", ) - .item( - OptionalService { - compose_profile: None, - repositories: vec![Repository::new("lichess-org", "mobile")].into(), - }, - "Mobile app", - "Flutter-based mobile app", - ) - .item( - OptionalService { - compose_profile: None, - repositories: vec![Repository::new("lichess-org", "dartchess")].into(), - }, - "Dartchess", - "standalone chess library for mobile platforms", - ) .item( OptionalService { compose_profile: None, @@ -693,45 +661,6 @@ fn hostname(mut config: Config) -> std::io::Result<()> { outro(format!("✔ Local Lichess URL set to http://{hostname}:8080")) } -fn mobile_setup(mut config: Config) -> std::io::Result<()> { - intro("On your Android phone, open Developer Options > Wireless Debugging")?; - - let phone_ip = match config.phone_ip { - Some(ip) => input("Your phone's private IP address").default_input(&ip), - None => input("Your phone's private IP address").placeholder("192.168.x.x or 10.x.x.x"), - } - .interact()?; - - let connection_port: u16 = input("Connection port") - .validate(|input: &String| validate_string_length(input, 5)) - .interact()?; - - info("Tap `Pair device with pairing code`")?; - - let pairing_code: u32 = input("Pairing code") - .validate(|input: &String| validate_string_length(input, 6)) - .interact()?; - let pairing_port: u16 = input("Pairing port") - .validate(|input: &String| validate_string_length(input, 5)) - .interact()?; - - config.phone_ip = Some(phone_ip); - config.connection_port = Some(connection_port); - config.pairing_code = Some(pairing_code); - config.pairing_port = Some(pairing_port); - config.save()?; - - outro("Pairing and connecting to phone...") -} - -fn validate_string_length(input: &str, length: usize) -> Result<(), String> { - if input.len() == length { - Ok(()) - } else { - Err(format!("Value should be {length} digits in length")) - } -} - fn welcome(config: Config) -> std::io::Result<()> { intro("Your Lichess development environment is starting!")?; @@ -762,25 +691,6 @@ fn welcome(config: Config) -> std::io::Result<()> { outro("🚀") } -fn flutter(config: Config) -> std::io::Result<()> { - let url = if Gitpod::is_host() { - gitpod_public()?; - Gitpod::load().url - } else { - config.lila_url.expect("Missing lila_url") - }; - - if url.contains("localhost") { - error("To run the Flutter app against your development site, change the lila URL to a hostname that can be resolved from other network devices (instead of `localhost`).")?; - return note("To fix, run:", "./lila-docker hostname"); - } - - outro("On your local machine, start Flutter with this command:")?; - println!("\nflutter run -v \\\n --dart-define LICHESS_HOST={url} \\\n --dart-define LICHESS_WS_HOST={url}"); - - Ok(()) -} - fn gitpod_public() -> std::io::Result<()> { if !Gitpod::is_host() { return Err(std::io::Error::new( @@ -843,10 +753,6 @@ mod tests { setup_api_tokens: Some(false), lila_domain: Some("baz:8080".to_string()), lila_url: Some("http://baz:8080".to_string()), - phone_ip: Some("1.2.3.4".to_string()), - connection_port: Some(1234), - pairing_code: Some(901234), - pairing_port: Some(5678), } .to_env(); @@ -864,10 +770,6 @@ mod tests { "SETUP_API_TOKENS=false", "LILA_DOMAIN=baz:8080", "LILA_URL=http://baz:8080", - "PHONE_IP=1.2.3.4", - "CONNECTION_PORT=1234", - "PAIRING_CODE=901234", - "PAIRING_PORT=5678" ] .join("\n") ); @@ -887,10 +789,6 @@ mod tests { setup_api_tokens: None, lila_domain: Some("baz:8080".to_string()), lila_url: Some("http://baz:8080".to_string()), - phone_ip: None, - connection_port: None, - pairing_code: None, - pairing_port: None, } .to_env(); diff --git a/lila-docker b/lila-docker index d8d38eb9..ee92bed0 100755 --- a/lila-docker +++ b/lila-docker @@ -165,15 +165,6 @@ run_hostname() { fi } -run_mobile() { - rust_cmd mobile - adb pair $PHONE_IP:$PAIRING_PORT $PAIRING_CODE - adb connect $PHONE_IP:$CONNECTION_PORT - adb reverse tcp:9663 tcp:8080 - adb reverse tcp:9664 tcp:8080 - echo "Run "flutter run" in ./repos/mobile to start the app" -} - rust_cmd() { if command -v rustup &> /dev/null; then # if the host has Rust installed, use it directly @@ -231,8 +222,6 @@ show_help() { echo " build Pre-fetch and pre-build all the images necessary for the containers" echo " format Run the code formatter to match Lichess code style" echo " hostname Set the hostname to something different than the default localhost" - echo " mobile For mobile app development. Pair and connect to a mobile device" - echo " flutter Get the 'flutter run' command with the URL arguments pre-configured" echo " db Reset and re-seed the database with fresh fake data" echo " lila clean Run 'sbt clean' in the lila container. Useful if there are compilation errors" echo " lila restart Restart the lila container to apply changes to the codebase" @@ -271,9 +260,6 @@ case "$@" in hostname) run_hostname ;; - mobile) - run_mobile - ;; db) reset_database ;; @@ -289,9 +275,6 @@ case "$@" in "gitpod public") rust_cmd gitpod_public ;; - "flutter") - rust_cmd flutter - ;; "add-services") add_services ;;