From 5d66c80d99b15be3da781ddba3f6f4d40fe51646 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Wed, 24 May 2023 15:07:33 -0700 Subject: [PATCH 01/15] Cleaner up shell.nix by removing bash commands and replacing them with just recipes. --- justfile | 28 +++++++++++++ scripts/install_openssl.sh | 48 ++++++++++++++++++++++ scripts/update_path.sh | 20 +++++++++ shell.nix | 83 -------------------------------------- 4 files changed, 96 insertions(+), 83 deletions(-) create mode 100644 justfile create mode 100644 scripts/install_openssl.sh create mode 100644 scripts/update_path.sh diff --git a/justfile b/justfile new file mode 100644 index 000000000..ed2b6090b --- /dev/null +++ b/justfile @@ -0,0 +1,28 @@ +scripts_dir := "scripts" + +# Check if Rust is installed, if not install it +install-rust: + @if ! command -v rustc &> /dev/null; then \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \ + fi + +# Check if wasm32-unknown-unknown target is installed, if not install it +install-wasm-target: + @if ! rustup target list --installed | grep -q "wasm32-unknown-unknown"; then \ + rustup target add wasm32-unknown-unknown; \ + fi + +# Check if OpenSSL 1.1 is installed +install-openssl: + @if ! (command -v openssl &> /dev/null && openssl version | grep -q "OpenSSL 1.1"); then \ + . {{scripts_dir}}/install_openssl.sh; \ + fi + +# Check if cosmo is installed, if not install it +install-cosmo: + @if ! command -v cosmo &> /dev/null; then \ + bash -c "$(curl -fsSL https://cosmonic.sh/install.sh)"; \ + . {{scripts_dir}}/update_path.sh; \ + fi + +all: install-rust install-wasm-target install-openssl install-cosmo diff --git a/scripts/install_openssl.sh b/scripts/install_openssl.sh new file mode 100644 index 000000000..a6dc47d88 --- /dev/null +++ b/scripts/install_openssl.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Check if OpenSSL 1.1 is installed +if ! (command -v openssl &> /dev/null && openssl version | grep -q "OpenSSL 1.1"); then + + # Check the architecture and install OpenSSL 1.1 if needed + if [[ $(uname -m) == "arm64" ]]; then + if [[ "$OSTYPE" == "darwin"* ]]; then + # MacOS M1 installation + if ! command -v brew &> /dev/null; then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi + + export PATH="/opt/homebrew/bin:$PATH" + + brew install openssl@1.1 + + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Check for Debian-based system + if grep -qi 'debian' /etc/os-release; then + # Ubuntu ARM installation + + apt update && apt install curl -y + + curl -s https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh | bash + + apt install wash + + curl -fLO http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1n-0+deb11u4_arm64.deb + + dpkg -i libssl1.1_1.1.1n-0+deb11u4_arm64.deb + + else + echo "This script is designed for Debian-based systems only." + exit 1 + fi + + else + echo "Unsupported system type." + exit 1 + fi + + else + echo "This script is designed for arm64 systems only." + exit 1 + fi + +fi diff --git a/scripts/update_path.sh b/scripts/update_path.sh new file mode 100644 index 000000000..81b100e22 --- /dev/null +++ b/scripts/update_path.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Get the current shell name +current_shell="$(basename ${builtins.getEnv "SHELL"})" + +# Update the corresponding configuration file based on the current shell +if [[ "$current_shell" == "bash" ]]; then + cat >> "${builtins.getEnv "HOME"}/.bashrc" <> "${builtins.getEnv "HOME"}/.zshrc" < /dev/null; then - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - fi - - # Check if wasm32-unknown-unknown target is installed, if not install it - if ! rustup target list --installed | grep -q "wasm32-unknown-unknown"; then - rustup target add wasm32-unknown-unknown - fi - - - # Check if OpenSSL 1.1 is installed - if ! (command -v openssl &> /dev/null && openssl version | grep -q "OpenSSL 1.1"); then - - # Check the architecture and install OpenSSL 1.1 if needed - if [[ $(uname -m) == "arm64" ]]; then - if [[ "$OSTYPE" == "darwin"* ]]; then - # MacOS M1 installation - if ! command -v brew &> /dev/null; then - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - fi - - export PATH="/opt/homebrew/bin:$PATH" - - brew install openssl@1.1 - - elif [[ "$OSTYPE" == "linux-gnu"* ]]; then - # Check for Debian-based system - if grep -qi 'debian' /etc/os-release; then - # Ubuntu ARM installation - - apt update && apt install curl -y - - curl -s https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh | bash - - apt install wash - - curl -fLO http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1n-0+deb11u4_arm64.deb - - dpkg -i libssl1.1_1.1.1n-0+deb11u4_arm64.deb - - else - echo "This script is designed for Debian-based systems only." - exit 1 - fi - - else - echo "Unsupported system type." - exit 1 - fi - - else - echo "This script is designed for arm64 systems only." - exit 1 - fi - - fi - - # Check if cosmo is installed, if not install it - if ! command -v cosmo &> /dev/null; then - bash -c "$(curl -fsSL https://cosmonic.sh/install.sh)" - - # Get the current shell name - current_shell="$(basename ${builtins.getEnv "SHELL"})" - - # Update the corresponding configuration file based on the current shell - if [[ "$current_shell" == "bash" ]]; then - cat >> "${builtins.getEnv "HOME"}/.bashrc" <> "${builtins.getEnv "HOME"}/.zshrc" < Date: Wed, 24 May 2023 16:56:17 -0700 Subject: [PATCH 02/15] Updated README. --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 1a17cf3f0..6e5ab966c 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,90 @@ - Here is the complete set of instructions: +# Nexus -1. Clone the Nexus repository +Welcome to the Nexus! This README will guide you through setting up your development environment and getting started with the project. + +## Prerequisites + +Before you begin, make sure you have the following installed on your system: + +- [Nix](https://nixos.org) +- [Git](https://git-scm.com/) +- [Rust](https://www.rust-lang.org/) +- wasm32-unknown-unknown target +- [OpenSSL 1.1](https://www.openssl.org/) +- [Cosmoonic](https://cosmonic.com) + +## Getting Started + +1. Clone the repository and navigate to the project directory: ```bash -git clone https://github.com/nexus +git clone https://github.com/plurigrid/nexus.git +cd nexus ``` -2. Enter the Nix environment +2. Start nix shell and run the following command to install all required dependencies: ```bash nix-shell +make all ``` -This will activate the flox environment defined in the nexus/flox.nix file. This environment has all the necessary dependencies installed to build and run your project. +This will automatically check for and install Rust, wasm32-unknown-unknown target, OpenSSL 1.1, and Cosmo CLI if they are not already installed on your system. -3. Run cosmo - -Now you can use cosmo launch your project: +3. Create a new actor using Cosmo CLI: ```bash -cosmo +cosmo new actor ``` -**If this is your first run of cosmo**, it will automatically start the tutorial. +Replace `` with your desired project name. -**If not your first run**, you can start the tutorial with: +4. Navigate to your newly created project directory: ```bash -cosmo tutorial hello +cd ``` -4. Explaining the components +5. Edit `src/lib.rs` file in your favorite text editor. -- flox is a tool for managing declarative Nix-based environments. The nexus/flox.nix file defines an environment with all the dependencies for your project. -- cosmo is a tool for building and deploying WebAssembly actors. You use it to build and launch your actor from within the flox environment. -- Nix is a purely functional package manager that is used by flox to define environments. +The default file content looks like this: -5. Installation (if not already completed) +```rust +use wasmbus_rpc::actor::prelude::*; +use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, HttpServerReceiver}; -Follow the instructions to install flox and configure your system to use it. This will install the necessary tools to get started with the Nexus project. +#[derive(Debug, Default, Actor, HealthResponder)] +#[services(Actor, HttpServer)] +struct DuckActor {} -- Install Nix (if not already installed) -- Install flox +/// Implementation of the HttpServer capability contract +#[async_trait] +impl HttpServer for DuckActor { + async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult { + Ok(HttpResponse::ok("message")) + } +} +``` -You now have all the necessary components installed and configured to build and run the Nexus project! Let me know if you have any other questions. +You can modify the file to accommodate more text like this: + +```rust +use wasmbus_rpc::actor::prelude::*; +use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, HttpServerReceiver}; + +#[derive(Debug, Default, Actor, HealthResponder)] +#[services(Actor, HttpServer)] +struct HelloActor {} + +/// Implementation of the HTTP server capability +#[async_trait] +impl HttpServer for HelloActor { + async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult { + let message: &str = r#"message"#; + + HttpResponse::ok(message) + } +} +``` + +Now you're all set! You can start building your project and explore the Nexus repository. Happy coding! From 875b385d79f4f66ed08b428f8ed680acbb75e3e0 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Wed, 24 May 2023 17:37:37 -0700 Subject: [PATCH 03/15] Update README.md --- README.md | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e5ab966c..e6c112043 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, Http #[derive(Debug, Default, Actor, HealthResponder)] #[services(Actor, HttpServer)] -struct DuckActor {} +struct Actor {} /// Implementation of the HttpServer capability contract #[async_trait] -impl HttpServer for DuckActor { +impl HttpServer for Actor { async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult { Ok(HttpResponse::ok("message")) } @@ -74,17 +74,45 @@ use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, Http #[derive(Debug, Default, Actor, HealthResponder)] #[services(Actor, HttpServer)] -struct HelloActor {} +struct Actor {} /// Implementation of the HTTP server capability #[async_trait] -impl HttpServer for HelloActor { +impl HttpServer for Actor { async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult { let message: &str = r#"message"#; - HttpResponse::ok(message) + Ok(HttpResponse::ok(message)) } } + +``` +## Launching the Project + +1. Build and sign your actor: + +```bash +cosmo build ``` -Now you're all set! You can start building your project and explore the Nexus repository. Happy coding! +2. Launch the actor using Cosmo CLI: + +```bash +cosmo launch +``` + +3. Navigate to [Cosmonic App](https://app.cosmonic.com) and sign in with your account. + +4. In the Logic view, you should see the new actor you just launched. + +5. To make your actor accessible from the web, launch a new provider for an HTTP server with the following OCI URL: `cosmonic.azurecr.io/httpserver_wormhole:0.5.3`. Give the link a name, and note that the HTTP server must be launched on a Cosmonic Manager resource. + +6. Once the HTTP server is launched, link it to your actor. + +7. Launch a wormhole and connect it to your actor link (the HTTP server and the actor). + +8. Your actor should now be accessible at the domain of the wormhole followed by `.cosmonic.app`. For example: `https://white-morning-5041.cosmonic.app`. + +Now you can access your project from any web browser using the provided URL! + +You're all set! You can start building your project and explore the Nexus repository. Happy coding! From 0f4c13fc4346a7904963ee02b4ec2b3bad03d653 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 01:19:57 -0700 Subject: [PATCH 04/15] Updated justfile, added script to set shell path, and fixed Cargo.toml version issue. --- Cargo.toml | 2 +- justfile | 3 +++ scripts/update_source.sh | 17 +++++++++++++++++ shell.nix | 1 - 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 scripts/update_source.sh diff --git a/Cargo.toml b/Cargo.toml index 5ad443271..4bc7a83e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nexus" version = "0.0.0" -edition = "2033" +edition = "2021" [dependencies] c2pa = "0.21.0" diff --git a/justfile b/justfile index ed2b6090b..26d292139 100644 --- a/justfile +++ b/justfile @@ -4,18 +4,21 @@ scripts_dir := "scripts" install-rust: @if ! command -v rustc &> /dev/null; then \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \ + . {{scripts_dir}}/update_path.sh; \ fi # Check if wasm32-unknown-unknown target is installed, if not install it install-wasm-target: @if ! rustup target list --installed | grep -q "wasm32-unknown-unknown"; then \ rustup target add wasm32-unknown-unknown; \ + . {{scripts_dir}}/update_path.sh; \ fi # Check if OpenSSL 1.1 is installed install-openssl: @if ! (command -v openssl &> /dev/null && openssl version | grep -q "OpenSSL 1.1"); then \ . {{scripts_dir}}/install_openssl.sh; \ + . {{scripts_dir}}/update_path.sh; \ fi # Check if cosmo is installed, if not install it diff --git a/scripts/update_source.sh b/scripts/update_source.sh new file mode 100644 index 000000000..0c4c8c11a --- /dev/null +++ b/scripts/update_source.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Detect the current shell +current_shell=$(basename "$SHELL") + +# Run the appropriate command based on the detected shell +case $current_shell in + bash)" + source ~/.bashrc || source ~/.bash_profile + ;; + zsh) + source ~/.zshrc + ;; + *) + exit 1 + ;; +esac diff --git a/shell.nix b/shell.nix index d58464979..9ad28b354 100644 --- a/shell.nix +++ b/shell.nix @@ -6,7 +6,6 @@ pkgs.mkShell { cargo tree poetry - openssl_1_1 vespa-cli ]; shellHook = '' From 5bd0c41792dff9d5e872bd326bc50e560b1be7d4 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 01:47:57 -0700 Subject: [PATCH 05/15] Added automatic Nix install if not present on system. --- justfile | 6 +++++- scripts/install_nix.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 scripts/install_nix.sh diff --git a/justfile b/justfile index 26d292139..5d8a5bd51 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,9 @@ scripts_dir := "scripts" +# Check if Nix is installed, if not install it based on the platform +install-nix: {{scripts_dir}}/install_nix.sh + @bash {{scripts_dir}}/install_nix.sh + # Check if Rust is installed, if not install it install-rust: @if ! command -v rustc &> /dev/null; then \ @@ -28,4 +32,4 @@ install-cosmo: . {{scripts_dir}}/update_path.sh; \ fi -all: install-rust install-wasm-target install-openssl install-cosmo +all: install-nix install-rust install-wasm-target install-openssl install-cosmo diff --git a/scripts/install_nix.sh b/scripts/install_nix.sh new file mode 100644 index 000000000..f3bd00c2a --- /dev/null +++ b/scripts/install_nix.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Check if Nix is installed +if ! command -v nix --help >/dev/null 2>&1; then + # Delete problematic backup files for bash and zsh if they exist + if [ -f "/etc/bash.bashrc.backup-before-nix" ]; then + sudo rm -f /etc/bash.bashrc.backup-before-nix + fi + + if [ -f "/etc/bashrc.backup-before-nix" ]; then + sudo rm -f /etc/bashrc.backup-before-nix + fi + + if [ -f "/etc/zshrc.backup-before-nix" ]; then + sudo rm -f /etc/zshrc.backup-before-nix + fi + + # Determine the platform (Linux or macOS) + case `uname` in + Linux*) + echo "Error: Nix package manager is not installed. Installing Nix for Linux..." + sh <(curl -L https://nixos.org/nix/install) --daemon + ;; + Darwin*) + echo "Error: Nix package manager is not installed. Installing Nix for macOS..." + sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume + ;; + *) + echo "Unsupported platform for Nix installation" + exit 1; + ;; + esac + +else + echo "Nix package manager is already installed." +fi From 1c1245535a722caa175731573a051950e63f6c62 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 01:58:07 -0700 Subject: [PATCH 06/15] fixed syntax error in nix just recipe. --- justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 5d8a5bd51..4cb6914b6 100644 --- a/justfile +++ b/justfile @@ -1,8 +1,8 @@ scripts_dir := "scripts" # Check if Nix is installed, if not install it based on the platform -install-nix: {{scripts_dir}}/install_nix.sh - @bash {{scripts_dir}}/install_nix.sh +install-nix: + . {{scripts_dir}}/install_nix.sh; \ # Check if Rust is installed, if not install it install-rust: From 28491b751579309e15abb9b56bc90623b609f9c3 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 02:04:14 -0700 Subject: [PATCH 07/15] fixed syntax error in install_nix.sh. --- scripts/install_nix.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_nix.sh b/scripts/install_nix.sh index f3bd00c2a..a668a922a 100644 --- a/scripts/install_nix.sh +++ b/scripts/install_nix.sh @@ -19,11 +19,11 @@ if ! command -v nix --help >/dev/null 2>&1; then case `uname` in Linux*) echo "Error: Nix package manager is not installed. Installing Nix for Linux..." - sh <(curl -L https://nixos.org/nix/install) --daemon + curl -L https://nixos.org/nix/install | sh --daemon - ;; Darwin*) echo "Error: Nix package manager is not installed. Installing Nix for macOS..." - sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume + curl -L https://nixos.org/nix/install | sh --darwin-use-unencrypted-nix-store-volume - ;; *) echo "Unsupported platform for Nix installation" From 61cd6685f419ec2318e7d8c1e1010009626c3f0a Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 02:13:01 -0700 Subject: [PATCH 08/15] Fixed syntax error in update_path.sh --- scripts/update_path.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/update_path.sh b/scripts/update_path.sh index 81b100e22..796a8061f 100644 --- a/scripts/update_path.sh +++ b/scripts/update_path.sh @@ -1,19 +1,19 @@ #!/bin/bash # Get the current shell name -current_shell="$(basename ${builtins.getEnv "SHELL"})" +current_shell="$(basename "$SHELL")" # Update the corresponding configuration file based on the current shell if [[ "$current_shell" == "bash" ]]; then - cat >> "${builtins.getEnv "HOME"}/.bashrc" <> "${HOME}/.bashrc" <> "${builtins.getEnv "HOME"}/.zshrc" <> "${HOME}/.zshrc" < Date: Thu, 25 May 2023 02:24:43 -0700 Subject: [PATCH 09/15] Added automatic path setting to install-cosmo just recipe. --- justfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/justfile b/justfile index 4cb6914b6..1bc11b576 100644 --- a/justfile +++ b/justfile @@ -29,7 +29,14 @@ install-openssl: install-cosmo: @if ! command -v cosmo &> /dev/null; then \ bash -c "$(curl -fsSL https://cosmonic.sh/install.sh)"; \ - . {{scripts_dir}}/update_path.sh; \ + current_shell=$$(basename "$$SHELL"); \ + if [ "$$current_shell" == "bash" ]; then \ + echo "export PATH=\"/Users/nexus/.cosmo/bin:\$$${PATH}\"" >> "${HOME}/.bashrc" && source "${HOME}/.bashrc"; \ + elif [ "$$current_shell" == "zsh" ]; then \ + echo "export PATH=\"/Users/nexus/.cosmo/bin:\$$${PATH}\"" >> "${HOME}/.zshrc" && source "${HOME}/.zshrc"; \ + else \ + echo "Unsupported shell: $$current_shell"; \ + fi; \ fi all: install-nix install-rust install-wasm-target install-openssl install-cosmo From 6cdc1f6aa943c0f68dc0b5e73b7f867d1995e45b Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 02:27:08 -0700 Subject: [PATCH 10/15] Updated installation check in install-rust just recipe. --- justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 1bc11b576..573d6eba8 100644 --- a/justfile +++ b/justfile @@ -6,7 +6,7 @@ install-nix: # Check if Rust is installed, if not install it install-rust: - @if ! command -v rustc &> /dev/null; then \ + @if ! command -v rustup &> /dev/null; then \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \ . {{scripts_dir}}/update_path.sh; \ fi @@ -37,6 +37,6 @@ install-cosmo: else \ echo "Unsupported shell: $$current_shell"; \ fi; \ - fi + fiai all: install-nix install-rust install-wasm-target install-openssl install-cosmo From fa8bc623c84090657a371d1914a16646f90d13f3 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 02:32:20 -0700 Subject: [PATCH 11/15] Fixed typo in install-cosmo just recipe. --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 573d6eba8..e4af25599 100644 --- a/justfile +++ b/justfile @@ -37,6 +37,6 @@ install-cosmo: else \ echo "Unsupported shell: $$current_shell"; \ fi; \ - fiai + fi; \ all: install-nix install-rust install-wasm-target install-openssl install-cosmo From 943ad3901648bf629951ff3cb5fb8b95342c46ce Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 02:41:03 -0700 Subject: [PATCH 12/15] Fixed typo cuasing path shell source to not be reloaded in justfile. --- justfile | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/justfile b/justfile index e4af25599..78bed21d1 100644 --- a/justfile +++ b/justfile @@ -6,37 +6,31 @@ install-nix: # Check if Rust is installed, if not install it install-rust: - @if ! command -v rustup &> /dev/null; then \ + @if ! command -v rustc &> /dev/null; then \ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \ - . {{scripts_dir}}/update_path.sh; \ + . {{scripts_dir}}/update_source.sh; \ fi # Check if wasm32-unknown-unknown target is installed, if not install it install-wasm-target: @if ! rustup target list --installed | grep -q "wasm32-unknown-unknown"; then \ rustup target add wasm32-unknown-unknown; \ - . {{scripts_dir}}/update_path.sh; \ + . {{scripts_dir}}/update_source.sh; \ fi # Check if OpenSSL 1.1 is installed install-openssl: @if ! (command -v openssl &> /dev/null && openssl version | grep -q "OpenSSL 1.1"); then \ . {{scripts_dir}}/install_openssl.sh; \ - . {{scripts_dir}}/update_path.sh; \ + . {{scripts_dir}}/update_source.sh; \ fi # Check if cosmo is installed, if not install it install-cosmo: @if ! command -v cosmo &> /dev/null; then \ bash -c "$(curl -fsSL https://cosmonic.sh/install.sh)"; \ - current_shell=$$(basename "$$SHELL"); \ - if [ "$$current_shell" == "bash" ]; then \ - echo "export PATH=\"/Users/nexus/.cosmo/bin:\$$${PATH}\"" >> "${HOME}/.bashrc" && source "${HOME}/.bashrc"; \ - elif [ "$$current_shell" == "zsh" ]; then \ - echo "export PATH=\"/Users/nexus/.cosmo/bin:\$$${PATH}\"" >> "${HOME}/.zshrc" && source "${HOME}/.zshrc"; \ - else \ - echo "Unsupported shell: $$current_shell"; \ - fi; \ - fi; \ + . {{scripts_dir}}/update_path.sh; \ + . {{scripts_dir}}/update_source.sh; \ + fi all: install-nix install-rust install-wasm-target install-openssl install-cosmo From d54795176cb7d74ce2a18d39a99e0ead85117ce3 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 02:46:49 -0700 Subject: [PATCH 13/15] Fixed syntac error in update_source.sh. --- scripts/update_source.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_source.sh b/scripts/update_source.sh index 0c4c8c11a..5e4eab7e7 100644 --- a/scripts/update_source.sh +++ b/scripts/update_source.sh @@ -5,7 +5,7 @@ current_shell=$(basename "$SHELL") # Run the appropriate command based on the detected shell case $current_shell in - bash)" + bash) source ~/.bashrc || source ~/.bash_profile ;; zsh) From 207389d91a0f3c1a9595d4eb98893db78a1f28f5 Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 03:15:36 -0700 Subject: [PATCH 14/15] Added support in update_source.sh for device with no zshrc made. --- scripts/update_source.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/update_source.sh b/scripts/update_source.sh index 5e4eab7e7..c4e0d131f 100644 --- a/scripts/update_source.sh +++ b/scripts/update_source.sh @@ -9,7 +9,12 @@ case $current_shell in source ~/.bashrc || source ~/.bash_profile ;; zsh) - source ~/.zshrc + if [ -f ~/.zshrc ]; then + source ~/.zshrc + else + touch ~/.zshrc + source ~/.zshrc + fi ;; *) exit 1 From 19d318946b1a4aac3ac1aa599a70fc1387a0cfae Mon Sep 17 00:00:00 2001 From: ajasibley <125228925+ajasibley@users.noreply.github.com> Date: Thu, 25 May 2023 12:23:07 -0700 Subject: [PATCH 15/15] Updated install_openssl.sh to properly set homebrew shell profile. Added message to just file promting user to restart shell following sucefull installation. Updated README to include steps for loging in to cosmonic and launching wasmCloust host. --- README.md | 28 ++++++++++++++++++++-------- justfile | 7 ++++++- scripts/install_openssl.sh | 7 +++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e6c112043..728cae165 100644 --- a/README.md +++ b/README.md @@ -89,29 +89,41 @@ impl HttpServer for Actor { ``` ## Launching the Project -1. Build and sign your actor: +1. Login to Cosmonic: + +```bash +cosmo login +``` + +2. Build and sign your actor: ```bash cosmo build ``` -2. Launch the actor using Cosmo CLI: +3. Start your wasmCloud host: + +```bash +cosmo up +``` + +4. Launch the actor using Cosmo CLI: ```bash cosmo launch ``` -3. Navigate to [Cosmonic App](https://app.cosmonic.com) and sign in with your account. +5. Navigate to [Cosmonic App](https://app.cosmonic.com) and sign in with your account. -4. In the Logic view, you should see the new actor you just launched. +6. In the Logic view, you should see the new actor you just launched. -5. To make your actor accessible from the web, launch a new provider for an HTTP server with the following OCI URL: `cosmonic.azurecr.io/httpserver_wormhole:0.5.3`. Give the link a name, and note that the HTTP server must be launched on a Cosmonic Manager resource. +7. To make your actor accessible from the web, launch a new provider for an HTTP server with the following OCI URL: `cosmonic.azurecr.io/httpserver_wormhole:0.5.3`. Give the link a name, and note that the HTTP server must be launched on a Cosmonic Manager resource. -6. Once the HTTP server is launched, link it to your actor. +8. Once the HTTP server is launched, link it to your actor. -7. Launch a wormhole and connect it to your actor link (the HTTP server and the actor). +9. Launch a wormhole and connect it to your actor link (the HTTP server and the actor). -8. Your actor should now be accessible at the domain of the wormhole followed by `.cosmonic.app`. For example: `https://white-morning-5041.cosmonic.app`. +10. Your actor should now be accessible at the domain of the wormhole followed by `.cosmonic.app`. For example: `https://white-morning-5041.cosmonic.app`. Now you can access your project from any web browser using the provided URL! diff --git a/justfile b/justfile index 78bed21d1..e95b1c308 100644 --- a/justfile +++ b/justfile @@ -33,4 +33,9 @@ install-cosmo: . {{scripts_dir}}/update_source.sh; \ fi -all: install-nix install-rust install-wasm-target install-openssl install-cosmo +# Print a message to restart the shell +restart-shell-message: + @echo + @echo "\033[1;33mPlease restart your shell to refresh the source before launching Cosmonic.\033[0m" + +all: install-nix install-rust install-wasm-target install-openssl install-cosmo restart-shell-message diff --git a/scripts/install_openssl.sh b/scripts/install_openssl.sh index a6dc47d88..9d22fc85d 100644 --- a/scripts/install_openssl.sh +++ b/scripts/install_openssl.sh @@ -9,6 +9,13 @@ if ! (command -v openssl &> /dev/null && openssl version | grep -q "OpenSSL 1.1" # MacOS M1 installation if ! command -v brew &> /dev/null; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> "$HOME/.zprofile" + + eval "$(/opt/homebrew/bin/brew shellenv)" + + echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc + fi export PATH="/opt/homebrew/bin:$PATH"