Skip to content

Commit

Permalink
First stable prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Jun 23, 2021
1 parent 1bd5315 commit f8c74f1
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 43 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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).
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions dev-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions scripts/setup-binaries.sh
Original file line number Diff line number Diff line change
@@ -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
36 changes: 21 additions & 15 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"}
7 changes: 6 additions & 1 deletion src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 0 additions & 8 deletions src-tauri/src/logs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use edit;
use log::LevelFilter;
use log4rs::{
self,
Expand All @@ -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")))
Expand Down
32 changes: 26 additions & 6 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(()) => (),
Expand All @@ -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(&[
Expand All @@ -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?;

Expand Down
8 changes: 6 additions & 2 deletions src-tauri/src/uis/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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(())
}
4 changes: 2 additions & 2 deletions src/components/InstallApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down

0 comments on commit f8c74f1

Please sign in to comment.