Feat: add dx as a package and move plugin to feature
This commit is contained in:
1 parent
7eeb72b929
commit
3f74b10e7c
8 files changed
+52
-22
No files matched your search
+1
-1
@@ -62,7 +62,7 @@ dioxus-tui = { path = "packages/dioxus-tui" }
|
|||||||
rink = { path = "packages/rink" }
|
rink = { path = "packages/rink" }
|
||||||
dioxus-native-core = { path = "packages/native-core" }
|
dioxus-native-core = { path = "packages/native-core" }
|
||||||
dioxus-native-core-macro = { path = "packages/native-core-macro" }
|
dioxus-native-core-macro = { path = "packages/native-core-macro" }
|
||||||
dioxus-rsx-rosetta = { path = "packages/rsx-rosetta" }
|
rsx-rosetta = { path = "packages/rsx-rosetta" }
|
||||||
dioxus-signals = { path = "packages/signals" }
|
dioxus-signals = { path = "packages/signals" }
|
||||||
dioxus-hot-reload = { path = "packages/hot-reload" }
|
dioxus-hot-reload = { path = "packages/hot-reload" }
|
||||||
dioxus-fullstack = { path = "packages/fullstack" }
|
dioxus-fullstack = { path = "packages/fullstack" }
|
||||||
|
|||||||
+20
-14
@@ -9,7 +9,6 @@ license = "MIT/Apache-2.0"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
# cli core
|
# cli core
|
||||||
clap = { version = "4.2", features = ["derive"] }
|
clap = { version = "4.2", features = ["derive"] }
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
@@ -58,10 +57,7 @@ flate2 = "1.0.22"
|
|||||||
tar = "0.4.38"
|
tar = "0.4.38"
|
||||||
zip = "0.6.2"
|
zip = "0.6.2"
|
||||||
tower = "0.4.12"
|
tower = "0.4.12"
|
||||||
|
|
||||||
syn = { version = "1.0", features = ["full", "extra-traits"] }
|
syn = { version = "1.0", features = ["full", "extra-traits"] }
|
||||||
|
|
||||||
|
|
||||||
proc-macro2 = { version = "1.0", features = ["span-locations"] }
|
proc-macro2 = { version = "1.0", features = ["span-locations"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
@@ -72,21 +68,31 @@ mlua = { version = "0.8.1", features = [
|
|||||||
"async",
|
"async",
|
||||||
"send",
|
"send",
|
||||||
"macros",
|
"macros",
|
||||||
] }
|
], optional = true }
|
||||||
ctrlc = "3.2.3"
|
ctrlc = "3.2.3"
|
||||||
# dioxus-rsx = "0.0.1"
|
|
||||||
gitignore = "1.0.7"
|
gitignore = "1.0.7"
|
||||||
|
|
||||||
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus" }
|
|
||||||
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus", features = ["hot-reload-context"] }
|
|
||||||
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", features = ["serialize"] }
|
|
||||||
dioxus-autofmt = { git = "https://github.com/DioxusLabs/dioxus" }
|
|
||||||
rsx-rosetta = { git = "https://github.com/DioxusLabs/dioxus" }
|
|
||||||
open = "4.1.0"
|
open = "4.1.0"
|
||||||
cargo-generate = "0.18.3"
|
cargo-generate = "0.18.3"
|
||||||
toml_edit = "0.19.11"
|
toml_edit = "0.19.11"
|
||||||
|
# dioxus-rsx = "0.0.1"
|
||||||
|
|
||||||
|
dioxus-autofmt = { workspace = true }
|
||||||
|
rsx-rosetta = { workspace = true }
|
||||||
|
dioxus-rsx = { workspace = true }
|
||||||
|
dioxus-html = { workspace = true, features = ["hot-reload-context"] }
|
||||||
|
dioxus-core = { workspace = true, features = ["serialize"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
plugin = ["mlua"]
|
||||||
|
|
||||||
|
# install path dx and dioxus as the same command
|
||||||
|
# so, they're not really aliases
|
||||||
|
# eventually dx will defer to the right version of dioxus
|
||||||
|
[[bin]]
|
||||||
|
path = "src/main.rs"
|
||||||
|
name = "dioxus"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
name = "dx"
|
||||||
name = "dioxus"
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#[cfg(feature = "plugin")]
|
||||||
use crate::plugin::PluginManager;
|
use crate::plugin::PluginManager;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -38,6 +39,7 @@ impl Build {
|
|||||||
.clone()
|
.clone()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
let _ = PluginManager::on_build_start(&crate_config, &platform);
|
let _ = PluginManager::on_build_start(&crate_config, &platform);
|
||||||
|
|
||||||
match platform.as_str() {
|
match platform.as_str() {
|
||||||
@@ -69,6 +71,7 @@ impl Build {
|
|||||||
)?;
|
)?;
|
||||||
file.write_all(temp.as_bytes())?;
|
file.write_all(temp.as_bytes())?;
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
let _ = PluginManager::on_build_finish(&crate_config, &platform);
|
let _ = PluginManager::on_build_finish(&crate_config, &platform);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ pub enum Commands {
|
|||||||
Config(config::Config),
|
Config(config::Config),
|
||||||
|
|
||||||
/// Manage plugins for dioxus cli
|
/// Manage plugins for dioxus cli
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
Plugin(plugin::Plugin),
|
Plugin(plugin::Plugin),
|
||||||
}
|
}
|
||||||
@@ -81,9 +82,11 @@ impl Display for Commands {
|
|||||||
Commands::Create(_) => write!(f, "create"),
|
Commands::Create(_) => write!(f, "create"),
|
||||||
Commands::Clean(_) => write!(f, "clean"),
|
Commands::Clean(_) => write!(f, "clean"),
|
||||||
Commands::Config(_) => write!(f, "config"),
|
Commands::Config(_) => write!(f, "config"),
|
||||||
Commands::Plugin(_) => write!(f, "plugin"),
|
|
||||||
Commands::Version(_) => write!(f, "version"),
|
Commands::Version(_) => write!(f, "version"),
|
||||||
Commands::Autoformat(_) => write!(f, "fmt"),
|
Commands::Autoformat(_) => write!(f, "fmt"),
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
Commands::Plugin(_) => write!(f, "plugin"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![cfg(feature = "plugin")]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// Build the Rust WASM app and all of its assets.
|
/// Build the Rust WASM app and all of its assets.
|
||||||
|
|||||||
@@ -21,4 +21,5 @@ pub use error::*;
|
|||||||
pub mod logging;
|
pub mod logging;
|
||||||
pub use logging::*;
|
pub use logging::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use dioxus_cli::{plugin::PluginManager, *};
|
use dioxus_cli::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
use dioxus_cli::plugin::PluginManager;
|
||||||
|
|
||||||
use Commands::*;
|
use Commands::*;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -9,14 +13,15 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
set_up_logging();
|
set_up_logging();
|
||||||
|
|
||||||
let dioxus_config = DioxusConfig::load()
|
let _dioxus_config = DioxusConfig::load()
|
||||||
.map_err(|e| anyhow!("Failed to load `Dioxus.toml` because: {e}"))?
|
.map_err(|e| anyhow!("Failed to load `Dioxus.toml` because: {e}"))?
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||||
DioxusConfig::default()
|
DioxusConfig::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
PluginManager::init(dioxus_config.plugin)
|
#[cfg(feature = "plugin")]
|
||||||
|
PluginManager::init(_dioxus_config.plugin)
|
||||||
.map_err(|e| anyhow!("🚫 Plugin system initialization failed: {e}"))?;
|
.map_err(|e| anyhow!("🚫 Plugin system initialization failed: {e}"))?;
|
||||||
|
|
||||||
match args.action {
|
match args.action {
|
||||||
@@ -45,6 +50,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.config()
|
.config()
|
||||||
.map_err(|e| anyhow!("🚫 Configuring new project failed: {}", e)),
|
.map_err(|e| anyhow!("🚫 Configuring new project failed: {}", e)),
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
Plugin(opts) => opts
|
Plugin(opts) => opts
|
||||||
.plugin()
|
.plugin()
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{builder, plugin::PluginManager, serve::Serve, BuildResult, CrateConfig, Result};
|
use crate::{builder, serve::Serve, BuildResult, CrateConfig, Result};
|
||||||
use axum::{
|
use axum::{
|
||||||
body::{Full, HttpBody},
|
body::{Full, HttpBody},
|
||||||
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
||||||
@@ -29,6 +29,10 @@ use tower_http::{
|
|||||||
cors::{Any, CorsLayer},
|
cors::{Any, CorsLayer},
|
||||||
ServiceBuilderExt,
|
ServiceBuilderExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
|
use plugin::PluginManager;
|
||||||
|
|
||||||
mod proxy;
|
mod proxy;
|
||||||
|
|
||||||
pub struct BuildManager {
|
pub struct BuildManager {
|
||||||
@@ -63,9 +67,10 @@ struct WsReloadState {
|
|||||||
|
|
||||||
pub async fn startup(port: u16, config: CrateConfig, start_browser: bool) -> Result<()> {
|
pub async fn startup(port: u16, config: CrateConfig, start_browser: bool) -> Result<()> {
|
||||||
// ctrl-c shutdown checker
|
// ctrl-c shutdown checker
|
||||||
let crate_config = config.clone();
|
let _crate_config = config.clone();
|
||||||
let _ = ctrlc::set_handler(move || {
|
let _ = ctrlc::set_handler(move || {
|
||||||
let _ = PluginManager::on_serve_shutdown(&crate_config);
|
#[cfg(feature = "plugin")]
|
||||||
|
let _ = PluginManager::on_serve_shutdown(&_crate_config);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -146,6 +151,7 @@ pub async fn startup_hot_reload(
|
|||||||
|
|
||||||
log::info!("🚀 Starting development server...");
|
log::info!("🚀 Starting development server...");
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
PluginManager::on_serve_start(&config)?;
|
PluginManager::on_serve_start(&config)?;
|
||||||
|
|
||||||
let dist_path = config.out_dir.clone();
|
let dist_path = config.out_dir.clone();
|
||||||
@@ -426,6 +432,8 @@ pub async fn startup_default(
|
|||||||
elapsed_time: res.elapsed_time,
|
elapsed_time: res.elapsed_time,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
let _ = PluginManager::on_serve_rebuild(
|
let _ = PluginManager::on_serve_rebuild(
|
||||||
chrono::Local::now().timestamp(),
|
chrono::Local::now().timestamp(),
|
||||||
e.paths,
|
e.paths,
|
||||||
@@ -459,6 +467,7 @@ pub async fn startup_default(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "plugin")]
|
||||||
PluginManager::on_serve_start(&config)?;
|
PluginManager::on_serve_start(&config)?;
|
||||||
|
|
||||||
let cors = CorsLayer::new()
|
let cors = CorsLayer::new()
|
||||||
|
|||||||
Reference in new issue
Block a user