Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Dec 11, 2023
2 parents ae76af0 + 49c550a commit 7a45c04
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 429 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- crate: glory
path: crates/glory
- crate: glory-cli
path: crates/glory-cli
path: crates/cli
steps:
- uses: dtolnay/rust-toolchain@stable
with:
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude = ["examples"]
resolver = "2"

[workspace.package]
version = "0.3.0"
version = "0.3.1"
authors = ["Chrislearn Young <[email protected]>"]
edition = "2021"
rust-version = "1.73"
Expand All @@ -21,16 +21,16 @@ license = "MIT OR Apache-2.0"
categories = ["web-programming::http-server", "web-programming::websocket", "network-programming", "asynchronous"]

[workspace.dependencies]
glory-core = { version = "0.3.0", path = "crates/core", default-features = false }#
glory-routing = { version = "0.3.0", path = "crates/routing", default-features = false }
glory-hot-reload = { version = "0.3.0", path = "crates/hot-reload" }
glory-core = { version = "0.3.1", path = "crates/core", default-features = false }#
glory-routing = { version = "0.3.1", path = "crates/routing", default-features = false }
glory-hot-reload = { version = "0.3.1", path = "crates/hot-reload" }

anyhow = "1"
async-trait = "0.1.42"
base64 = "0.21"
cfg-if = "1"
config = { version = "0.13", default-features = false, features = ["toml"] }
educe = "0.4"
educe = "0.5"
form_urlencoded = "1"
futures = "0.3"
futures-channel = { version = "0.3", default-features = true }
Expand All @@ -43,7 +43,7 @@ paste = "1"
percent-encoding = "2"
path-slash = "0.2"
regex = "1"
salvo = { version = "0.58", default-features = true }
salvo = { version = "0.60", default-features = true }
serde = { version = "1" }
serde_json = { version = "1" }
smallvec = "1"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Glory is a experimental rust web front framework modified from leptos.

Your can find examples in [examples](./examples/) folder.

Online example: [http://glory.rs:8000](http://glory.rs:8000).

## 🩸 Contributing

Contributions are absolutely, positively welcome and encouraged! Contributions come in many forms. You could:
Expand Down
59 changes: 27 additions & 32 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,48 @@ rust-version = { workspace = true }
[[bin]]
path = "src/main.rs"
name = "glory"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.0", features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
ansi_term = "0.12"
anyhow = { workspace = true }
log = "0.4"
flexi_logger = "0.27"
lightningcss = { version = "1.0.0-alpha.47", features = ["browserslist"] }
salvo = { workspace = true, features = ["websocket"] }
tokio = { version = "1.4", default-features = false, features = ["full"] }
# not using notify 5.0 because it uses Crossbeam which has an issue with tokio
notify = "4"
once_cell ={ workspace = true }
which = "5.0"
async-trait = "0.1.72"
brotli = { version = "3.4", features = ["default"] }
bytes = "1.4"
camino = "1.1"
cargo_metadata = { version = "0.18", features = ["builder"] }
serde_json = "1.0"
wasm-bindgen-cli-support = "0.2"
ansi_term = "0.12"

seahash = "4.1"
reqwest = { version = "0.11", features = ["blocking", "__tls", "default-tls", "native-tls-crate", "json"], default-features = false }
clap = { version = "4.0", features = ["derive"] }
derive_more = "0.99"
dirs = "5.0"
camino = "1.1"
dotenvy = "0.15"
itertools = "0.11"
derive_more = "0.99"
flate2 = "1.0"
zip = { version = "0.6", default-features = false, features = ["deflate"] }
tar = "0.4"
dunce = "1.0"
bytes = "1.4"
flate2 = "1.0"
flexi_logger = "0.27"
# glory-hot-reload = { git = "https://github.com/glory-rs/glory", version = "0.4.8" }
glory-hot-reload = { workspace = true }
itertools = "0.12"
lightningcss = { version = "1.0.0-alpha.51", features = ["browserslist"] }
log = "0.4"
# not using notify 5.0 because it uses Crossbeam which has an issue with tokio
notify = "4"
once_cell = { workspace = true }
reqwest = { version = "0.11", features = ["blocking", "__tls", "default-tls", "native-tls-crate", "json"], default-features = false }
salvo = { workspace = true, features = ["websocket"] }
seahash = "4.1"
semver = "1.0.18"
async-trait = "0.1.72"
serde = { workspace = true, features = ["derive"] }
serde_json = "1.0"
tar = "0.4"
tokio = { version = "1.4", default-features = false, features = ["full"] }
wasm-bindgen-cli-support = "0.2"
which = "5.0"
zip = { version = "0.6", default-features = false, features = ["deflate"] }
zstd = { version = "0.13", features = ["default"] }

[dev-dependencies]
insta = { version = "1.31.0", features = ["yaml"] }
temp-dir = "0.1"

[features]
full_tests = []
no_downloads = []

# The profile that 'cargo dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"
no_downloads = []
31 changes: 27 additions & 4 deletions crates/cli/src/compile/front.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use std::collections::HashMap;
use std::fs::File;
use std::io::Write;
use std::sync::Arc;

use brotli::CompressorWriter;
use camino::{Utf8Path, Utf8PathBuf};
use flate2::write::GzEncoder;
use tokio::process::Child;
use tokio::{process::Command, sync::broadcast, task::JoinHandle};
use wasm_bindgen_cli_support::Bindgen;

use super::ChangeSet;
use crate::config::Project;
use crate::ext::fs;
Expand All @@ -14,10 +23,6 @@ use crate::{
},
logger::GRAY,
};
use camino::{Utf8Path, Utf8PathBuf};
use tokio::process::Child;
use tokio::{process::Command, sync::broadcast, task::JoinHandle};
use wasm_bindgen_cli_support::Bindgen;

pub async fn front(proj: &Arc<Project>, changes: &ChangeSet) -> JoinHandle<Result<Outcome<Product>>> {
let proj = proj.clone();
Expand Down Expand Up @@ -102,6 +107,24 @@ async fn bindgen(proj: &Project) -> Result<Outcome<Product>> {
}
}

let data = fs::read(&wasm_file.dest).await?;
let br_file = File::create(format!("{}.br", wasm_file.dest.as_str()))?;
let mut br_writer = CompressorWriter::new(
br_file,
32 * 1024, // 32 KiB buffer
11, // BROTLI_PARAM_QUALITY
22, // BROTLI_PARAM_LGWIN
);
br_writer.write_all(&data)?;

let zstd_data = zstd::encode_all(&*data, 21)?;
let mut zstd_file = File::create(format!("{}.zst", wasm_file.dest.as_str()))?;
zstd_file.write_all(&zstd_data)?;

let gzip_file = File::create(format!("{}.gz", wasm_file.dest.as_str()))?;
let mut gzip_encoder = GzEncoder::new(gzip_file, flate2::Compression::best());
gzip_encoder.write_all(&data)?;

let mut js_changed = false;

js_changed |= write_snippets(proj, bindgen.snippets()).await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/compile/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn browser_lists(query: &str) -> Result<Option<Browsers>> {
async fn process_css(proj: &Project, css: String) -> Result<Product> {
let browsers = browser_lists(&proj.style.browser_query).context("glory.style.browser_query")?;

let mut stylesheet = StyleSheet::parse(&css, ParserOptions::default()).map_err(|e| anyhow!("{e}"))?;
let mut stylesheet = StyleSheet::parse(&css, ParserOptions::default()).map_err(|e| anyhow!("lightingcss: {e}"))?;

if proj.release {
stylesheet.minify(MinifyOptions::default())?;
Expand Down
12 changes: 10 additions & 2 deletions crates/cli/src/compile/tailwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub async fn compile_tailwind(_proj: &Project, tw_conf: &TailwindConfig) -> Resu

if done {
log::info!("Tailwind finished {}", GRAY.paint(line));
Ok(Outcome::Success(output.stdout()))
let css = std::fs::read_to_string(&tw_conf.output_file).context("read tailwind output")?;
Ok(Outcome::Success(css))
} else {
log::warn!("Tailwind failed {}", GRAY.paint(line));
println!("{}\n{}", output.stdout(), output.stderr());
Expand Down Expand Up @@ -64,7 +65,14 @@ async fn create_default_tailwind_config(tw_conf: &TailwindConfig) -> Result<()>
pub async fn tailwind_process(cmd: &str, tw_conf: &TailwindConfig) -> Result<(String, Command)> {
let tailwind = Exe::Tailwind.get().await.dot()?;

let args: Vec<&str> = vec!["--input", tw_conf.input_file.as_str(), "--config", tw_conf.config_file.as_str()];
let args: Vec<&str> = vec![
"--input",
tw_conf.input_file.as_str(),
"--output",
tw_conf.output_file.as_str(),
"--config",
tw_conf.config_file.as_str(),
];
let line = format!("{} {}", cmd, args.join(" "));
let mut command = Command::new(tailwind);
command.args(args);
Expand Down
11 changes: 10 additions & 1 deletion crates/cli/src/config/tailwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use anyhow::{bail, Result};
#[derive(Clone, Debug)]
pub struct TailwindConfig {
pub input_file: Utf8PathBuf,
pub output_file: Utf8PathBuf,
pub config_file: Utf8PathBuf,
}

Expand All @@ -20,12 +21,20 @@ impl TailwindConfig {
return Ok(None);
};

let mut output_file = Utf8PathBuf::new();
output_file.push("target/front/");
output_file.push(&input_file);

let config_file = conf.config_dir.join(
conf.tailwind_config_file
.clone()
.unwrap_or_else(|| Utf8PathBuf::from("tailwind.config.js")),
);

Ok(Some(Self { input_file, config_file }))
Ok(Some(Self {
input_file,
output_file,
config_file,
}))
}
}
Loading

0 comments on commit 7a45c04

Please sign in to comment.