Skip to content

Commit

Permalink
1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed Mar 5, 2024
1 parent 4ae8d63 commit 81dfe61
Show file tree
Hide file tree
Showing 36 changed files with 3,969 additions and 388 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.lock

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

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmo"
version = "1.0.14"
version = "1.0.15"
edition = "2021"
authors = ["Zwiterrion <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand Down
16 changes: 10 additions & 6 deletions cli/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,19 @@ async fn build(path: Option<String>, server: Option<String>, host: Host, client_

let plugin = plugin::read_plugin(&complete_path);

let authorization = format!("Basic {}",
general_purpose::STANDARD_NO_PAD.encode(format!("{}:{}",
configuration.get(WASMO_CLIENT_ID).unwrap_or(&"".to_string()),
configuration.get(WASMO_CLIENT_SECRET).unwrap_or(&"".to_string()))));

let request = Request::builder()
.method(Method::POST)
.uri(format!(
"{}/api/plugins/build",
configuration.get(WASMO_SERVER).unwrap()
))
.header("Content-Type", "application/json")
.header("Authorization",
general_purpose::STANDARD_NO_PAD.encode(format!("{}:{}",
configuration.get(WASMO_CLIENT_ID).unwrap_or(&"".to_string()),
configuration.get(WASMO_CLIENT_SECRET).unwrap_or(&"".to_string()))))
.header("Authorization", &authorization)
.body(Body::from(serde_json::to_string(&plugin).unwrap()))
.unwrap();

Expand All @@ -480,7 +482,7 @@ async fn build(path: Option<String>, server: Option<String>, host: Host, client_
match resp {
Err(e) => panic!("{:#?}", e),
Ok(k) => {
logger::log(format!("Build call status: {}", k.status()));
logger::indent_println(format!("Build call status: {}", k.status()));

if k.status() == 403 || k.status() == 401 {
return Err(WasmoError::BuildInterrupt("unauthorized".to_string()));
Expand All @@ -495,7 +497,9 @@ async fn build(path: Option<String>, server: Option<String>, host: Host, client_
.unwrap();

let build_result =
websocket::ws_listen(&configuration.get(WASMO_SERVER).unwrap(), &result.queue_id)
websocket::ws_listen(&configuration.get(WASMO_SERVER).unwrap(),
&result.queue_id,
&authorization)
.await;

match build_result {
Expand Down
5 changes: 0 additions & 5 deletions cli/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ pub fn check_loading() {
}
}

pub fn log(_: String) {
// let mut logger = Logger::new();
// logger.log(str);
}

pub fn error(str: String) {
check_loading();
let mut logger = Logger::new();
Expand Down
19 changes: 13 additions & 6 deletions cli/src/websocket.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures_util::StreamExt;
use std::fmt;
use tokio::io::AsyncReadExt;
use tokio_tungstenite::{connect_async, tungstenite::protocol::Message};
use tokio_tungstenite::{connect_async, tungstenite::{client::IntoClientRequest, protocol::Message}};

#[derive(PartialEq, Clone, Copy, Debug)]
pub enum BuildResult {
Expand Down Expand Up @@ -41,20 +41,27 @@ async fn read_stdin(tx: futures_channel::mpsc::UnboundedSender<Message>) {
}
}

pub async fn ws_listen(url: &String, channel: &String) -> BuildResult {
pub async fn ws_listen(url: &String, channel: &String, authorization: &String) -> BuildResult {
crate::logger::loading(format!("<yellow>Listening</> websocket from {}", url));

let (stdin_tx, _) = futures_channel::mpsc::unbounded();
tokio::spawn(read_stdin(stdin_tx));

let (ws_stream, _) = connect_async(format!(
let mut request = format!(
"{}/{}",
url.replace("http://", "ws://")
.replace("https://", "wss://"),
channel
))
.await
.expect("Failed to connect");
)
.into_client_request()
.unwrap();

let headers = request.headers_mut();
headers.insert("Authorization", authorization.parse().unwrap());

let (ws_stream, _) = connect_async(request)
.await
.expect("Failed to connect");

let (_write, mut read) = ws_stream.split();

Expand Down
Empty file.

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

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

12 changes: 12 additions & 0 deletions server/build/67005445-91be-4e69-a107-d6dd14fb89f1/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const esbuild = require('esbuild');

esbuild
.build({
entryPoints: ['index.js'],
outdir: 'dist',
bundle: true,
sourcemap: true,
minify: false, // might want to use true for production build
format: 'cjs', // needs to be CJS for now
target: ['es2020'] // don't go over es2020 because quickjs doesn't support it
})
6 changes: 6 additions & 0 deletions server/build/67005445-91be-4e69-a107-d6dd14fb89f1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function greet() {
const name = Host.inputString()
Host.outputString(`Hello, ${name}`)
}

module.exports = { greet }

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

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

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

Binary file not shown.

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

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

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

Binary file not shown.
Loading

0 comments on commit 81dfe61

Please sign in to comment.