diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1e2e70c5..8f0b7a80d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,6 +89,15 @@ jobs: if: matrix.build == 'macos' run: brew install p7zip + - name: Install vcpkg OpenSSL (Windows) + if :matrix.build == 'windows' + run: | + git clone https://github.com/microsoft/vcpkg + .\vcpkg\bootstrap-vcpkg.bat + .\vcpkg\vcpkg install openssl:x64-windows + env: + VCPKGRS_DYNAMIC: 1 + - name: Build (Linux) if: matrix.build == 'linux' run: | @@ -104,6 +113,7 @@ jobs: run: cargo build --release env: RUSTFLAGS: -Ctarget-feature=+crt-static + VCPKGRS_DYNAMIC: 1 - name: Create artifact directory run: | diff --git a/Cargo.toml b/Cargo.toml index df3327e10..9a25d8936 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ lazy_static = "1.4.0" log = "0.4.11" notify = "4.0.15" number_prefix = "0.4.0" -openssl = { version = '0.10.29', optional = true } +openssl = { version = "0.10.29"} percent-encoding = "2.1.0" predicates = "1.0.5" prettytable-rs = "0.8.0" diff --git a/src/commands/login.rs b/src/commands/login.rs new file mode 100644 index 000000000..48e0a3027 --- /dev/null +++ b/src/commands/login.rs @@ -0,0 +1,3 @@ +//use crate::login; + +pub fn run() {} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index b76bb3c3f..04f455593 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -6,6 +6,7 @@ pub mod dev; pub mod generate; pub mod init; pub mod kv; +pub mod login; mod preview; pub mod publish; pub mod route; diff --git a/src/lib.rs b/src/lib.rs index d7e7c1af8..95f219bf8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ pub mod http; pub mod install; pub mod installer; pub mod kv; +pub mod login; pub mod settings; pub mod sites; pub mod tail; diff --git a/src/login/mod.rs b/src/login/mod.rs new file mode 100644 index 000000000..5a4b8eb97 --- /dev/null +++ b/src/login/mod.rs @@ -0,0 +1,22 @@ +//use crate::terminal::{interactive::confirm, open_browser}; + +//use openssl::base64; +use openssl::rsa::Rsa; + +pub fn run() -> Result<(), failure::Error> { + let rsa = Rsa::generate(1024)?; + let _ = rsa.public_key_to_pem_pkcs1()?; + + Ok(()) +} + +#[cfg(test)] +mod tests { + use openssl::rsa::Rsa; + + #[test] + fn test_rsa() { + let rsa = Rsa::generate(1024).unwrap(); + rsa.public_key_to_pem_pkcs1().unwrap(); + } +} diff --git a/src/preview/mod.rs b/src/preview/mod.rs index 8597c383c..afe8ab278 100644 --- a/src/preview/mod.rs +++ b/src/preview/mod.rs @@ -10,7 +10,6 @@ pub use request_payload::RequestPayload; mod upload; pub use upload::upload; -use std::process::Command; use std::sync::mpsc::channel; use std::thread; @@ -22,7 +21,7 @@ use crate::build; use crate::http; use crate::settings::global_user::GlobalUser; use crate::settings::toml::Target; -use crate::terminal::message; +use crate::terminal::{message, open_browser}; use crate::watch::watch_and_build; pub fn preview( @@ -93,22 +92,6 @@ pub struct PreviewOpt { pub headless: bool, } -fn open_browser(url: &str) -> Result<(), failure::Error> { - let _output = if cfg!(target_os = "windows") { - let url_escaped = url.replace("&", "^&"); - let windows_cmd = format!("start {}", url_escaped); - Command::new("cmd").args(&["/C", &windows_cmd]).output()? - } else if cfg!(target_os = "linux") { - let linux_cmd = format!(r#"xdg-open "{}""#, url); - Command::new("sh").arg("-c").arg(&linux_cmd).output()? - } else { - let mac_cmd = format!(r#"open "{}""#, url); - Command::new("sh").arg("-c").arg(&mac_cmd).output()? - }; - - Ok(()) -} - fn client_request(payload: &RequestPayload, script_id: &str, sites_preview: bool) { let client = http::client(); diff --git a/src/terminal/browser.rs b/src/terminal/browser.rs new file mode 100644 index 000000000..a8ce5bbba --- /dev/null +++ b/src/terminal/browser.rs @@ -0,0 +1,17 @@ +use std::process::Command; + +pub fn open_browser(url: &str) -> Result<(), failure::Error> { + let _output = if cfg!(target_os = "windows") { + let url_escaped = url.replace("&", "^&"); + let windows_cmd = format!("start {}", url_escaped); + Command::new("cmd").args(&["/C", &windows_cmd]).output()? + } else if cfg!(target_os = "linux") { + let linux_cmd = format!(r#"xdg-open "{}""#, url); + Command::new("sh").arg("-c").arg(&linux_cmd).output()? + } else { + let mac_cmd = format!(r#"open "{}""#, url); + Command::new("sh").arg("-c").arg(&mac_cmd).output()? + }; + + Ok(()) +} diff --git a/src/terminal/mod.rs b/src/terminal/mod.rs index 73dff93cc..a4187af9e 100644 --- a/src/terminal/mod.rs +++ b/src/terminal/mod.rs @@ -1,4 +1,6 @@ +mod browser; pub mod emoji; pub mod interactive; pub mod message; pub mod styles; +pub use browser::open_browser;