Merge pull request #78 from Demonthos/crate_out_dir

This commit is contained in:
YuKun Liu 2022-10-31 09:22:30 -07:00 committed by GitHub
commit 9c5b2cc2ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 12 deletions

52
Cargo.lock generated
View file

@ -554,6 +554,8 @@ dependencies = [
"clap", "clap",
"colored 2.0.0", "colored 2.0.0",
"convert_case", "convert_case",
"dioxus-core",
"dioxus-rsx",
"dirs 4.0.0", "dirs 4.0.0",
"fern", "fern",
"flate2", "flate2",
@ -582,6 +584,38 @@ dependencies = [
"zip 0.6.2", "zip 0.6.2",
] ]
[[package]]
name = "dioxus-core"
version = "0.2.1"
source = "git+https://github.com/dioxuslabs/dioxus/#f89cd204557f09febebf1afc48f418ad6ebc5254"
dependencies = [
"backtrace",
"bumpalo",
"dyn-clone",
"futures-channel",
"futures-util",
"indexmap",
"log",
"longest-increasing-subsequence",
"once_cell",
"rustc-hash",
"serde",
"slab",
"smallvec",
]
[[package]]
name = "dioxus-rsx"
version = "0.0.0"
source = "git+https://github.com/dioxuslabs/dioxus/#f89cd204557f09febebf1afc48f418ad6ebc5254"
dependencies = [
"dioxus-core",
"proc-macro2",
"quote",
"serde",
"syn",
]
[[package]] [[package]]
name = "dirs" name = "dirs"
version = "1.0.5" version = "1.0.5"
@ -613,6 +647,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "dyn-clone"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2"
[[package]] [[package]]
name = "encode_unicode" name = "encode_unicode"
version = "0.3.6" version = "0.3.6"
@ -1286,6 +1326,12 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "longest-increasing-subsequence"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86"
[[package]] [[package]]
name = "lru-cache" name = "lru-cache"
version = "0.1.2" version = "0.1.2"
@ -1877,6 +1923,12 @@ version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.20.6" version = "0.20.6"

View file

@ -1,5 +1,6 @@
use super::*; use super::*;
use std::{ use std::{
fs::create_dir_all,
io::Write, io::Write,
path::PathBuf, path::PathBuf,
process::{Command, Stdio}, process::{Command, Stdio},
@ -71,19 +72,19 @@ impl Serve {
pub fn regen_dev_page(crate_config: &CrateConfig) -> Result<()> { pub fn regen_dev_page(crate_config: &CrateConfig) -> Result<()> {
let serve_html = gen_page(&crate_config.dioxus_config, true); let serve_html = gen_page(&crate_config.dioxus_config, true);
let mut file = std::fs::File::create( let dist_path = crate_config.crate_dir.join(
crate_config crate_config
.crate_dir .dioxus_config
.join( .application
crate_config .out_dir
.dioxus_config .clone()
.application .unwrap_or_else(|| PathBuf::from("dist")),
.out_dir );
.clone() if !dist_path.is_dir() {
.unwrap_or_else(|| PathBuf::from("dist")), create_dir_all(&dist_path)?;
) }
.join("index.html"), let index_path = dist_path.join("index.html");
)?; let mut file = std::fs::File::create(index_path)?;
file.write_all(serve_html.as_bytes())?; file.write_all(serve_html.as_bytes())?;
Ok(()) Ok(())