Merge branch 'master' into maybe-sync-signal

This commit is contained in:
ealmloff authored and GitHub committed 2024-01-08 16:27:11 -06:00
commit c7e104c0f0
127 files changed
+4604 -2940

No files matched your search

+1 -1
View File
@@ -139,7 +139,7 @@ async fn format_file(
///
/// Doesn't do mod-descending, so it will still try to format unreachable files. TODO.
async fn autoformat_project(check: bool) -> Result<()> {
let crate_config = crate::CrateConfig::new(None)?;
let crate_config = dioxus_cli_config::CrateConfig::new(None)?;
let files_to_format = get_project_files(&crate_config);
+4 -10
View File
@@ -1,8 +1,9 @@
use crate::assets::WebAssetConfigDropGuard;
#[cfg(feature = "plugin")]
use crate::plugin::PluginManager;
use crate::server::fullstack::FullstackServerEnvGuard;
use crate::server::fullstack::FullstackWebEnvGuard;
use crate::{cfg::Platform, WebAssetConfigDropGuard};
use dioxus_cli_config::Platform;
use super::*;
@@ -16,7 +17,7 @@ pub struct Build {
impl Build {
pub fn build(self, bin: Option<PathBuf>, target_dir: Option<&std::path::Path>) -> Result<()> {
let mut crate_config = crate::CrateConfig::new(bin)?;
let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
if let Some(target_dir) = target_dir {
crate_config.target_dir = target_dir.to_path_buf();
}
@@ -96,14 +97,7 @@ impl Build {
let mut file = std::fs::File::create(
crate_config
.crate_dir
.join(
crate_config
.dioxus_config
.application
.out_dir
.clone()
.unwrap_or_else(|| PathBuf::from("dist")),
)
.join(crate_config.dioxus_config.application.out_dir.clone())
.join("index.html"),
)?;
file.write_all(temp.as_bytes())?;
+5 -4
View File
@@ -1,4 +1,5 @@
use core::panic;
use dioxus_cli_config::ExecutableType;
use std::{fs::create_dir_all, str::FromStr};
use tauri_bundler::{BundleSettings, PackageSettings, SettingsBuilder};
@@ -62,7 +63,7 @@ impl From<PackageType> for tauri_bundler::PackageType {
impl Bundle {
pub fn bundle(self, bin: Option<PathBuf>) -> Result<()> {
let mut crate_config = crate::CrateConfig::new(bin)?;
let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
// change the release state.
crate_config.with_release(self.build.release);
@@ -89,9 +90,9 @@ impl Bundle {
let package = crate_config.manifest.package.unwrap();
let mut name: PathBuf = match &crate_config.executable {
crate::ExecutableType::Binary(name)
| crate::ExecutableType::Lib(name)
| crate::ExecutableType::Example(name) => name,
ExecutableType::Binary(name)
| ExecutableType::Lib(name)
| ExecutableType::Example(name) => name,
}
.into();
if cfg!(windows) {
+1 -15
View File
@@ -1,5 +1,4 @@
use clap::ValueEnum;
use serde::Serialize;
use dioxus_cli_config::Platform;
use super::*;
@@ -154,19 +153,6 @@ pub struct ConfigOptsServe {
pub cargo_args: Vec<String>,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Serialize, Deserialize, Debug)]
pub enum Platform {
#[clap(name = "web")]
#[serde(rename = "web")]
Web,
#[clap(name = "desktop")]
#[serde(rename = "desktop")]
Desktop,
#[clap(name = "fullstack")]
#[serde(rename = "fullstack")]
Fullstack,
}
/// Config options for the bundling system.
#[derive(Clone, Debug, Default, Deserialize, Parser)]
pub struct ConfigOptsBundle {
+1 -1
View File
@@ -47,7 +47,7 @@ async fn check_file_and_report(path: PathBuf) -> Result<()> {
///
/// Doesn't do mod-descending, so it will still try to check unreachable files. TODO.
async fn check_project_and_report() -> Result<()> {
let crate_config = crate::CrateConfig::new(None)?;
let crate_config = dioxus_cli_config::CrateConfig::new(None)?;
let mut files_to_check = vec![];
collect_rs_files(&crate_config.crate_dir, &mut files_to_check);
+2 -6
View File
@@ -7,7 +7,7 @@ pub struct Clean {}
impl Clean {
pub fn clean(self, bin: Option<PathBuf>) -> Result<()> {
let crate_config = crate::CrateConfig::new(bin)?;
let crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
let output = Command::new("cargo")
.arg("clean")
@@ -19,11 +19,7 @@ impl Clean {
return custom_error!("Cargo clean failed.");
}
let out_dir = crate_config
.dioxus_config
.application
.out_dir
.unwrap_or_else(|| PathBuf::from("dist"));
let out_dir = crate_config.dioxus_config.application.out_dir;
if crate_config.crate_dir.join(&out_dir).is_dir() {
remove_dir_all(crate_config.crate_dir.join(&out_dir))?;
}
+7 -2
View File
@@ -1,3 +1,5 @@
use dioxus_cli_config::crate_root;
use super::*;
/// Dioxus config file controls
@@ -26,7 +28,7 @@ pub enum Config {
impl Config {
pub fn config(self) -> Result<()> {
let crate_root = crate::cargo::crate_root()?;
let crate_root = crate_root()?;
match self {
Config::Init {
name,
@@ -48,7 +50,10 @@ impl Config {
log::info!("🚩 Init config file completed.");
}
Config::FormatPrint {} => {
println!("{:#?}", crate::CrateConfig::new(None)?.dioxus_config);
println!(
"{:#?}",
dioxus_cli_config::CrateConfig::new(None)?.dioxus_config
);
}
Config::CustomHtml {} => {
let html_path = crate_root.join("index.html");
+2 -1
View File
@@ -15,9 +15,10 @@ use crate::{
cfg::{ConfigOptsBuild, ConfigOptsServe},
custom_error,
error::Result,
gen_page, server, CrateConfig, Error,
gen_page, server, Error,
};
use clap::{Parser, Subcommand};
use dioxus_cli_config::CrateConfig;
use html_parser::Dom;
use serde::Deserialize;
use std::{
+9 -15
View File
@@ -1,3 +1,5 @@
use dioxus_cli_config::Platform;
use super::*;
use std::{fs::create_dir_all, io::Write, path::PathBuf};
@@ -11,7 +13,7 @@ pub struct Serve {
impl Serve {
pub async fn serve(self, bin: Option<PathBuf>) -> Result<()> {
let mut crate_config = crate::CrateConfig::new(bin)?;
let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
let serve_cfg = self.serve.clone();
// change the relase state.
@@ -32,9 +34,6 @@ impl Serve {
crate_config.set_features(self.serve.features.unwrap());
}
// Subdirectories don't work with the server
crate_config.dioxus_config.web.app.base_path = None;
if let Some(target) = self.serve.target {
crate_config.set_target(target);
}
@@ -47,7 +46,7 @@ impl Serve {
.unwrap_or(crate_config.dioxus_config.application.default_platform);
match platform {
cfg::Platform::Web => {
Platform::Web => {
// generate dev-index page
Serve::regen_dev_page(&crate_config, self.serve.skip_assets)?;
@@ -60,10 +59,10 @@ impl Serve {
)
.await?;
}
cfg::Platform::Desktop => {
Platform::Desktop => {
server::desktop::startup(crate_config.clone(), &serve_cfg).await?;
}
cfg::Platform::Fullstack => {
Platform::Fullstack => {
server::fullstack::startup(crate_config.clone(), &serve_cfg).await?;
}
}
@@ -73,14 +72,9 @@ impl Serve {
pub fn regen_dev_page(crate_config: &CrateConfig, skip_assets: bool) -> Result<()> {
let serve_html = gen_page(crate_config, true, skip_assets);
let dist_path = crate_config.crate_dir.join(
crate_config
.dioxus_config
.application
.out_dir
.clone()
.unwrap_or_else(|| PathBuf::from("dist")),
);
let dist_path = crate_config
.crate_dir
.join(crate_config.dioxus_config.application.out_dir.clone());
if !dist_path.is_dir() {
create_dir_all(&dist_path)?;
}