Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved commands sub-system #168

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ playwright/.cache/

**/.env

.DS_Store
.DS_Store

.idea/
94 changes: 68 additions & 26 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ reqwest = { version = "0.11", features = [
"__tls",
"default-tls",
"native-tls-crate",
"json",
], default-features = false }
dirs = "4.0"
camino = "1.1"
Expand All @@ -63,6 +64,8 @@ tar = "0.4"
dunce = "1.0"
bytes = "1.4"
leptos_hot_reload = { git = "https://github.com/leptos-rs/leptos", version = "0.4.0" }
semver = "1.0.18"
async-trait = "0.1.72"

[dev-dependencies]
insta = { version = "1.23", features = ["yaml"] }
Expand Down
2 changes: 1 addition & 1 deletion src/command/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub async fn run_loop(proj: &Arc<Project>) -> Result<()> {
// spawn separate style-update process
tokio::spawn({
let changes = changes.to_owned();
let proj = Arc::clone(&proj);
let proj = Arc::clone(proj);
async move {
let style = compile::style(&proj, &changes).await;
if let Ok(Ok(Outcome::Success(Product::Style(_)))) = style.await {
Expand Down
2 changes: 2 additions & 0 deletions src/compile/front.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ async fn bindgen(proj: &Project) -> Result<Outcome<Product>> {
let wasm_file = &proj.lib.wasm_file;
let interrupt = Interrupt::subscribe_any();

log::info!("Front compiling WASM");

// see:
// https://github.com/rustwasm/wasm-bindgen/blob/main/crates/cli-support/src/lib.rs#L95
// https://github.com/rustwasm/wasm-bindgen/blob/main/crates/cli/src/bin/wasm-bindgen.rs#L13
Expand Down
2 changes: 1 addition & 1 deletion src/compile/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn build(proj: &Arc<Project>) -> Result<Outcome<Product>> {
(Failed, _) | (_, Failed) => return Ok(Failed),
(Success(css), Success(tw)) => format!("{css}\n{tw}"),
};
Ok(Outcome::Success(process_css(proj, css).await?))
Ok(Success(process_css(proj, css).await?))
}

fn browser_lists(query: &str) -> Result<Option<Browsers>> {
Expand Down
4 changes: 2 additions & 2 deletions src/compile/tailwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub async fn compile_tailwind(
}

async fn create_default_tailwind_config(tw_conf: &TailwindConfig) -> Result<()> {
let contents = r##"/** @type {import('tailwindcss').Config} */
let contents = r#"/** @type {import('tailwindcss').Config} */
module.exports = {
content: {
relative: true,
Expand All @@ -65,7 +65,7 @@ async fn create_default_tailwind_config(tw_conf: &TailwindConfig) -> Result<()>
},
plugins: [],
}
"##;
"#;
fs::write(&tw_conf.config_file, contents).await
}

Expand Down
7 changes: 7 additions & 0 deletions src/config/dotenvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::ProjectConfig;
use crate::ext::anyhow::Result;
use camino::{Utf8Path, Utf8PathBuf};
use std::{env, fs};
use crate::ext::exe;

pub fn load_dotenvs(directory: &Utf8Path) -> Result<Option<Vec<(String, String)>>> {
let candidate = directory.join(".env");
Expand Down Expand Up @@ -49,6 +50,12 @@ fn overlay(conf: &mut ProjectConfig, envs: impl Iterator<Item = (String, String)
"LEPTOS_BIN_TARGET_TRIPLE" => conf.bin_target_triple = Some(val),
"LEPTOS_BIN_TARGET_DIR" => conf.bin_target_dir = Some(val),
"LEPTOS_BIN_CARGO_COMMAND" => conf.bin_cargo_command = Some(val),
// put these here to suppress the warning, but there's no
// good way at the moment to pull the ProjectConfig all the way to Exe
exe::ENV_VAR_LEPTOS_TAILWIND_VERSION => {},
exe::ENV_VAR_LEPTOS_SASS_VERSION => {},
exe::ENV_VAR_LEPTOS_CARGO_GENERATE_VERSION => {},
exe::ENV_VAR_LEPTOS_WASM_OPT_VERSION => {},
_ if key.starts_with("LEPTOS_") => {
log::warn!("Env {key} is not used by cargo-leptos")
}
Expand Down
4 changes: 1 addition & 3 deletions src/config/end2end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ pub struct End2EndConfig {

impl End2EndConfig {
pub fn resolve(config: &ProjectConfig) -> Option<Self> {
let Some(cmd) = &config.end2end_cmd else {
return None
};
let cmd = &config.end2end_cmd.to_owned()?;

let dir = config.end2end_dir.to_owned().unwrap_or_default();

Expand Down
Loading
Loading