From 5fdb14446bb88cddd89179e909081d757204c924 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Wed, 29 Dec 2021 12:03:18 -0500 Subject: [PATCH 1/4] wip: studio upgrades --- .vscode/settings.json | 4 +- Cargo.toml | 9 +- src/builder.rs | 26 ++++-- src/cli.rs | 45 ++++++++-- src/config.rs | 5 +- src/develop.rs | 76 ++++++++++++----- src/err.html | 19 +++++ src/error.rs | 3 + src/lib.rs | 29 +++++-- src/logging.rs | 2 - src/main.rs | 24 +----- src/studio.rs | 194 ++++++++++++++++++++++++++++++++++++++++++ src/translate.rs | 101 ++++++++++++++++++++++ tests/test.html | 32 +++++++ 14 files changed, 499 insertions(+), 70 deletions(-) create mode 100644 src/err.html create mode 100644 src/studio.rs create mode 100644 src/translate.rs create mode 100644 tests/test.html diff --git a/.vscode/settings.json b/.vscode/settings.json index 80f51cff8..1c68f97cc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "rust-analyzer.inlayHints.enable": false -} \ No newline at end of file + "rust-analyzer.inlayHints.enable": true +} diff --git a/Cargo.toml b/Cargo.toml index b57f28140..99d6ff539 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,14 +18,19 @@ argh = "0.1.4" serde = "1.0.120" serde_json = "1.0.61" async-std = { version = "1.9.0", features = ["attributes"] } -tide = "0.15.0" +tide = "0.16.0" fs_extra = "1.2.0" -cargo_toml = "0.8.1" +cargo_toml = "0.10.0" futures = "0.3.12" notify = "5.0.0-pre.4" rjdebounce = "0.2.1" tempfile = "3.2.0" +html_parser = "0.6.2" + +tui = { version = "0.15.0", features = ["crossterm"] } +crossterm = "0.19.0" +tui-template = { git = "https://github.com/jkelleyrtp/tui-builder.git" } [[bin]] diff --git a/src/builder.rs b/src/builder.rs index 6b61c8665..83a6d1de5 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,10 +1,13 @@ use crate::{ cli::BuildOptions, - config::{Config, ExecutableType}, - error::Result, + config::{CrateConfig, ExecutableType}, + error::{Error, Result}, }; use log::{info, warn}; -use std::{io::Write, process::Command}; +use std::{ + io::{Read, Write}, + process::Command, +}; use wasm_bindgen_cli_support::Bindgen; pub struct BuildConfig {} @@ -19,7 +22,7 @@ impl Default for BuildConfig { } } -pub fn build(config: &Config, _build_config: &BuildConfig) -> Result<()> { +pub fn build(config: &CrateConfig, _build_config: &BuildConfig) -> Result<()> { /* [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?) [2] Generate the appropriate build folders @@ -28,7 +31,7 @@ pub fn build(config: &Config, _build_config: &BuildConfig) -> Result<()> { [5] Link up the html page to the wasm module */ - let Config { + let CrateConfig { out_dir, crate_dir, target_dir, @@ -60,9 +63,16 @@ pub fn build(config: &Config, _build_config: &BuildConfig) -> Result<()> { }; let mut child = cmd.spawn()?; - let _err_code = child.wait()?; + let output = child.wait()?; - info!("Build complete!"); + if output.success() { + info!("Build complete!"); + } else { + log::error!("Build failed!"); + let mut reason = String::new(); + child.stderr.unwrap().read_to_string(&mut reason)?; + return Err(Error::BuildFailed(reason)); + } // [2] Establish the output directory structure let bindgen_outdir = out_dir.join("wasm"); @@ -129,6 +139,8 @@ fn gen_page(module: &str) -> String { +
+