From f8c74f19bc7f2c8bccc4d51a1ce07625299b72bf Mon Sep 17 00:00:00 2001 From: Guillem Cordoba Date: Wed, 23 Jun 2021 12:14:27 +0200 Subject: [PATCH] First stable prerelease --- README.md | 14 ++++++++++---- dev-setup.md | 3 +++ scripts/setup-binaries.sh | 13 +++++++++++++ src-tauri/Cargo.lock | 36 ++++++++++++++++++++--------------- src-tauri/Cargo.toml | 9 ++++----- src-tauri/src/config.rs | 7 ++++++- src-tauri/src/logs.rs | 8 -------- src-tauri/src/main.rs | 32 +++++++++++++++++++++++++------ src-tauri/src/uis/commands.rs | 8 ++++++-- src/components/InstallApp.vue | 4 ++-- 10 files changed, 91 insertions(+), 43 deletions(-) create mode 100644 scripts/setup-binaries.sh diff --git a/README.md b/README.md index a2d77097..d328269f 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ ## Installing the Launcher -0. Install `libgtksourceview`: +0. Install the necessary dependencies: ```bash -sudo apt-get install libgtksourceview-3.0-dev libwebkit2gtk-4.0-dev +sudo apt-get install libgtksourceview-3.0-dev libwebkit2gtk-4.0-dev libappindicator3-dev ``` > This step should not be needed once [Tauri supports it](https://github.com/tauri-apps/tauri/issues/1986). @@ -18,10 +18,12 @@ sudo apt-get install libgtksourceview-3.0-dev libwebkit2gtk-4.0-dev 2. Download the appropriate executable for your platform. 3. Execute the AppImage. +> Warning! This will replace your `$CONFIG_DIR/holochain/conductor-config.yaml`, if you have one from running `holochain -i`. + ## Usage ### Preparing your UI - + When your UI is served from the launcher, you will have the Holochain app interface available at `ws://localhost:8888`. You will also have the admin interface available at `ws://localhost:8889`, but its usage is discouraged as newer versions of the launcher will block any admin requests not coming from the Holochain Admin UI itself. There will be a call available in `AppWebsocket` that will prompt the user to do an action in the Holochain Admin UI, or similar (To Be Defined). @@ -45,11 +47,15 @@ The Holochain Launcher uses the same config and data locations as the main `holo To reset the launcher, it is enough to remove all the folders mentioned above and start the launcher again. +### Logs + +Logs can be found at `$DATA_DIR/holochain/launcher.log`. When reporting issues, please attach the contents of this file. + ## Support Right now only Linux amd64 is supported. MacOS will be available soon. Windows support will be blocked until Holochain core supports it. -There is a known issue that prevents the UIs from opening in chromium based browsers. For now the launcher will only open UIs in Firefox. +There is a known issue that prevents the UIs from opening in Chromium based browsers. For now the launcher will only open UIs in Firefox. ## Developer Setup diff --git a/dev-setup.md b/dev-setup.md index 22bfc2d8..e06c4070 100644 --- a/dev-setup.md +++ b/dev-setup.md @@ -4,8 +4,11 @@ Go through the [tauri developer setup](https://tauri.studio/en/docs/getting-star ## Project setup +This assumes that you have the `holochain`, `lair-keystore` and `caddy` binaries installed and available in your PATH + ```bash npm install +sh scripts/setup-binaries.sh ``` ### Compiles and hot-reloads for development diff --git a/scripts/setup-binaries.sh b/scripts/setup-binaries.sh new file mode 100644 index 00000000..81bd7fe6 --- /dev/null +++ b/scripts/setup-binaries.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +rm -rf src-tauri/bins/ +mkdir src-tauri/bins + +HOLOCHAIN_PATH=$(which holochain) +cp $HOLOCHAIN_PATH src-tauri/bins/holochain-x86_64-unknown-linux-gnu + +LAIR_PATH=$(which lair-keystore) +cp $LAIR_PATH src-tauri/bins/lair-keystore-x86_64-unknown-linux-gnu + +CADDY_PATH=$(which caddy) +cp $CADDY_PATH src-tauri/bins/caddy-x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 80a3c7c0..7adaaa09 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1352,16 +1352,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" -[[package]] -name = "edit" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cdd6936f8bd9782e28932eef853bfcd8548992ce5748bb3e7e88bad613d0ee0" -dependencies = [ - "tempfile", - "which 4.1.0", -] - [[package]] name = "either" version = "1.6.1" @@ -2093,18 +2083,19 @@ version = "0.1.0" dependencies = [ "base64", "chrono", - "edit", "flate2", "futures", "holochain_conductor_api_rust", "log", "log4rs", "open", + "open-file", "serde", "serde_json", "serde_yaml", "tauri", "tauri-build", + "tokio", "zip", ] @@ -3624,6 +3615,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "open-file" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9723e5a9ffe49d9fa0184ab852bff555ec26fb77cbc02928b967947a9ade3c2" + [[package]] name = "openssl" version = "0.10.34" @@ -5287,8 +5284,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.2.6" -source = "git+https://github.com/tauri-apps/tao?rev=01fc43b05ea41463d512c0e3497971edc543ac9d#01fc43b05ea41463d512c0e3497971edc543ac9d" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f2b1bbb775ce0235a26b51459c8a675da81eb95dfcaa16411be963661ef13f1" dependencies = [ "bitflags 1.2.1", "cairo-rs", @@ -5338,6 +5336,7 @@ dependencies = [ [[package]] name = "tauri" version = "1.0.0-beta.1" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "attohttpc", "base64", @@ -5379,6 +5378,7 @@ dependencies = [ [[package]] name = "tauri-build" version = "1.0.0-beta.0" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "anyhow", "proc-macro2", @@ -5391,6 +5391,7 @@ dependencies = [ [[package]] name = "tauri-codegen" version = "1.0.0-beta.0" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "blake3", "proc-macro2", @@ -5406,6 +5407,7 @@ dependencies = [ [[package]] name = "tauri-macros" version = "1.0.0-beta.1" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "proc-macro2", "quote 1.0.9", @@ -5416,6 +5418,7 @@ dependencies = [ [[package]] name = "tauri-runtime" version = "0.1.1" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "serde", "serde_json", @@ -5428,6 +5431,7 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" version = "0.1.1" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "ico", "infer", @@ -5442,6 +5446,7 @@ dependencies = [ [[package]] name = "tauri-utils" version = "1.0.0-beta.0" +source = "git+https://github.com/tauri-apps/tauri?rev=74e36c21dd1e3e12830bdc31dbb5fa54c13ad425#74e36c21dd1e3e12830bdc31dbb5fa54c13ad425" dependencies = [ "heck", "html5ever", @@ -6311,8 +6316,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.9.4" -source = "git+https://github.com/tauri-apps/wry?rev=6a1475ff76cbdd699df9329ab8e2181c2a794c96#6a1475ff76cbdd699df9329ab8e2181c2a794c96" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e03e8c0137b63202c1159a917fd4e172890d850a819b3e09f8b03933af6834" dependencies = [ "cocoa", "core-graphics 0.22.2", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 86f320d5..f0143f21 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -12,22 +12,23 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = {path = "../../../../tauri/core/tauri-build"} +tauri-build = {git = "https://github.com/tauri-apps/tauri", package = "tauri-build", rev = "74e36c21dd1e3e12830bdc31dbb5fa54c13ad425"} [dependencies] base64 = "0.13.0" chrono = {version = "0.4", features = ["serde"] } -edit = "0.1.3" flate2 = "1.0.20" futures = "0.3" holochain_conductor_api_rust = {git = "https://github.com/holochain/conductor-api-rust", rev = "4edf406b674d676f076bb19fdbe79fe5a1077c0d"} log = "0.4.14" log4rs = "1.0.0" open = "1" +open-file = "0.1.0" serde = {version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.8" -tauri = {path = "../../../../tauri/core/tauri", features = ["api-all", "menu", "system-tray"] } +tauri = {git = "https://github.com/tauri-apps/tauri", package = "tauri", rev = "74e36c21dd1e3e12830bdc31dbb5fa54c13ad425", features = ["api-all", "menu", "system-tray"] } +tokio = "1.7.0" zip = "0.5" [features] @@ -40,5 +41,3 @@ holo_hash = {git = "https://github.com/holochain/holochain", rev = "753ea0873cd6 holochain_zome_types = {git = "https://github.com/holochain/holochain", rev = "753ea0873cd6e4c7b3ba30ead2d815d5f61b5373", package = "holochain_zome_types"} lmdb-rkv = {git = "https://github.com/holochain/lmdb-rs.git"} rkv = {git = "https://github.com/holochain/rkv.git", branch = "master"} - -tao = {git = "https://github.com/tauri-apps/tao", rev = "01fc43b05ea41463d512c0e3497971edc543ac9d"} diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 0dc1cc60..e3f2fd39 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -71,7 +71,12 @@ fn initial_config(admin_port: u16, environment_path: PathBuf) -> String { network_type: quic_bootstrap bootstrap_service: https://bootstrap-staging.holo.host transport_pool: - - type: quic + - type: proxy + sub_transport: + type: quic + proxy_config: + type: remote_proxy_client + proxy_url: "kitsune-proxy://1IazkCHRw1DihmY89jQLcj5pqvyL4HD7EWggpk-NYEc/kitsune-quic/h/52.14.147.62/p/22224/--" "#, environment_path.into_os_string().to_str().unwrap(), keystore_data_path().into_os_string().to_str().unwrap(), diff --git a/src-tauri/src/logs.rs b/src-tauri/src/logs.rs index 97846dfe..f32c2a66 100644 --- a/src-tauri/src/logs.rs +++ b/src-tauri/src/logs.rs @@ -1,4 +1,3 @@ -use edit; use log::LevelFilter; use log4rs::{ self, @@ -10,13 +9,6 @@ use log4rs::{ use crate::config::logs_path; -pub fn open_logs() { - tauri::async_runtime::spawn(async move { - let _r = edit::edit_file(logs_path()); - println!("{:?}", _r); - }) -} - pub fn setup_logs() -> Result<(), String> { let logfile = FileAppender::builder() .encoder(Box::new(PatternEncoder::new("[{d}] {l} - {m}\n"))) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 98f06be6..90af3ef1 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -24,14 +24,17 @@ use crate::uis::caddy; use crate::uis::commands::{activate_app_ui, deactivate_app_ui, install_ui, open_app_ui}; fn main() { - setup_logs(); + if let Err(err) = setup_logs() { + println!("Error setting up the logs: {:?}", err); + } let quit = CustomMenuItem::new("quit".to_string(), "Quit"); let show_admin = CustomMenuItem::new("show_admin".to_string(), "Show Admin"); - let show_logs = CustomMenuItem::new("show_logs".to_string(), "Show Logs"); + let _show_logs = CustomMenuItem::new("show_logs".to_string(), "Show Logs"); let sys_tray_menu = SystemTrayMenu::new() - .add_item(show_logs) + // TODO: uncomment when async runtime works well + // .add_item(show_logs) .add_item(show_admin) .add_native_item(SystemTrayMenuItem::Separator) .add_item(quit); @@ -69,14 +72,14 @@ fn main() { } } "show_logs" => { - logs::open_logs(); + // logs::open_logs(); } _ => {} }, _ => {} } }) - .setup(|app| { + .setup(|_app| { tauri::async_runtime::block_on(async move { match launch_children_processes().await { Ok(()) => (), @@ -100,6 +103,23 @@ fn main() { async fn launch_children_processes() -> Result<(), String> { config::create_initial_config_if_necessary(); + + Command::new_sidecar("lair-keystore") + .or(Err(String::from("Can't find lair-keystore binary")))? + .args(&[ + "-d", + config::keystore_data_path() + .into_os_string() + .to_str() + .unwrap(), + ]) + .spawn() + .map_err(|err| format!("Failed to execute lair-keystore: {:?}", err))?; + + log::info!("Launched lair-keystore"); + + thread::sleep(Duration::from_millis(1000)); + Command::new_sidecar("holochain") .or(Err(String::from("Can't find holochain binary")))? .args(&[ @@ -114,7 +134,7 @@ async fn launch_children_processes() -> Result<(), String> { log::info!("Launched holochain"); - thread::sleep(Duration::from_millis(100)); + thread::sleep(Duration::from_millis(1000)); setup_conductor().await?; diff --git a/src-tauri/src/uis/commands.rs b/src-tauri/src/uis/commands.rs index d8ece6fc..2de6a87d 100644 --- a/src-tauri/src/uis/commands.rs +++ b/src-tauri/src/uis/commands.rs @@ -3,7 +3,6 @@ use crate::{ config::uis_data_path, uis::{caddy, utils::unzip_file}, }; -use log::trace; use open; use std::fs::{self, File}; @@ -61,9 +60,14 @@ pub fn open_app_ui(app_id: String) -> Result<(), String> { .ok_or("App not registered")?; let app_url = format!("http://localhost:{}", port); - log::info!("Opening app {} at {}...", app_id.clone(), app_url); let result = open::with_in_background(app_url.as_str(), "firefox"); + log::info!( + "Opening app {} at {}, result: {:?}", + app_id.clone(), + app_url, + result + ); Ok(()) } diff --git a/src/components/InstallApp.vue b/src/components/InstallApp.vue index 7d995ede..0c170160 100644 --- a/src/components/InstallApp.vue +++ b/src/components/InstallApp.vue @@ -94,12 +94,12 @@ export default defineComponent({ ); this.$store.commit("log", { log: "Installed app" }); - const response = await invoke("install_ui", { + await invoke("install_ui", { uiBundlePath: this.uiBundlePath, appId, }); this.$store.commit("log", { - log: `Installed UI ${JSON.stringify(response)}`, + log: `Installed UI`, }); } catch (e) { this.$store.commit("log", {