improve build times by extracting asset opt into its own crate (#3273)
* improve build types by extracing asset opt as a dylib * dont use dylib, but let regular workspace caching do the heavy lifting * add prebuild to cli for better lock contention * hoist deps * disable slow tests * re-enable sequential, debug=0 for dev * use vfs for windows * dont cache on failure, fix windows vfs caceh * free disk space re-order * add clippy + fmt to windows channel * yoink makefile * proper rustfmt/clippy on toolchain * set incremental to zero since cargo-cache disables it
This commit is contained in:
1 parent
79a2f023e7
commit
1cbfcde6cd
25 files changed
+550
-554
No files matched your search
@@ -0,0 +1,91 @@
|
||||
[package]
|
||||
name = "dioxus-cli-opt"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
authors = ["Jonathan Kelley", "Evan Almloff"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/DioxusLabs/dioxus/"
|
||||
homepage = "https://dioxuslabs.com"
|
||||
description = "CLI optimizations for dioxus-cli"
|
||||
keywords = ["dom", "ui", "gui", "react"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
manganis-core = { workspace = true }
|
||||
object = {version="0.36.0", features=["wasm"]}
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
const-serialize = { workspace = true, features = ["serde"] }
|
||||
tracing = { workspace = true }
|
||||
rayon = "1.8.0"
|
||||
|
||||
# Image compression/conversion
|
||||
# - JPEG
|
||||
mozjpeg = { version = "0.10.7", default-features = false, features = [
|
||||
"parallel",
|
||||
] }
|
||||
# - PNG
|
||||
imagequant = "4.2.0"
|
||||
png = "0.17.9"
|
||||
|
||||
# Image format/conversion
|
||||
image = { version = "0.25", features = ["avif"] }
|
||||
|
||||
# CSS Minification
|
||||
lightningcss = "1.0.0-alpha.60"
|
||||
|
||||
# Js minification - swc has introduces minor versions with breaking changes in the past so we pin all of their crates
|
||||
swc = "=0.283.0"
|
||||
swc_allocator = { version = "=0.1.8", default-features = false }
|
||||
swc_atoms = { version = "=0.6.7", default-features = false }
|
||||
swc_cached = { version = "=0.3.20", default-features = false }
|
||||
swc_common = { version = "=0.37.5", default-features = false }
|
||||
swc_compiler_base = { version = "=0.19.0", default-features = false }
|
||||
swc_config = { version = "=0.1.15", default-features = false }
|
||||
swc_config_macro = { version = "=0.1.4", default-features = false }
|
||||
swc_ecma_ast = { version = "=0.118.2", default-features = false }
|
||||
swc_ecma_codegen = { version = "=0.155.1", default-features = false }
|
||||
swc_ecma_codegen_macros = { version = "=0.7.7", default-features = false }
|
||||
swc_ecma_compat_bugfixes = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_common = { version = "=0.11.0", default-features = false }
|
||||
swc_ecma_compat_es2015 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2016 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2017 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2018 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2019 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2020 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2021 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2022 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es3 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_ext_transforms = { version = "=0.120.0", default-features = false }
|
||||
swc_ecma_lints = { version = "=0.100.0", default-features = false }
|
||||
swc_ecma_loader = { version = "=0.49.1", default-features = false }
|
||||
swc_ecma_minifier = { version = "=0.204.0", default-features = false }
|
||||
swc_ecma_parser = { version = "=0.149.1", default-features = false }
|
||||
swc_ecma_preset_env = { version = "=0.217.0", default-features = false, features = [
|
||||
"serde",
|
||||
] }
|
||||
swc_ecma_transforms = { version = "=0.239.0", default-features = false }
|
||||
swc_ecma_transforms_base = { version = "=0.145.0", default-features = false }
|
||||
swc_ecma_transforms_classes = { version = "=0.134.0", default-features = false }
|
||||
swc_ecma_transforms_compat = { version = "=0.171.0", default-features = false }
|
||||
swc_ecma_transforms_macros = { version = "=0.5.5", default-features = false }
|
||||
swc_ecma_transforms_module = { version = "=0.190.0", default-features = false }
|
||||
swc_ecma_transforms_optimization = { version = "=0.208.0", default-features = false }
|
||||
swc_ecma_transforms_proposal = { version = "=0.178.0", default-features = false }
|
||||
swc_ecma_transforms_react = { version = "=0.191.0", default-features = false }
|
||||
swc_ecma_transforms_typescript = { version = "=0.198.1", default-features = false }
|
||||
swc_ecma_usage_analyzer = { version = "=0.30.3", default-features = false }
|
||||
swc_ecma_utils = { version = "=0.134.2", default-features = false }
|
||||
swc_ecma_visit = { version = "=0.104.8", default-features = false }
|
||||
swc_eq_ignore_macros = { version = "=0.1.4", default-features = false }
|
||||
swc_error_reporters = { version = "=0.21.0", default-features = false }
|
||||
swc_fast_graph = { version = "=0.25.0", default-features = false }
|
||||
swc_macros_common = { version = "=0.3.13", default-features = false }
|
||||
swc_node_comments = { version = "=0.24.0", default-features = false }
|
||||
swc_timer = { version = "=0.25.0", default-features = false }
|
||||
swc_trace_macro = { version = "=0.1.3", default-features = false }
|
||||
swc_transform_common = { version = "=0.1.1", default-features = false }
|
||||
swc_typescript = { version = "=0.5.0", default-features = false }
|
||||
swc_visit = { version = "=0.6.2", default-features = false }
|
||||
browserslist-rs = { version = "=0.16.0" }
|
||||
File renamed without changes.
@@ -8,7 +8,7 @@ use super::{
|
||||
};
|
||||
|
||||
/// Process a specific file asset with the given options reading from the source and writing to the output path
|
||||
pub(crate) fn process_file_to(
|
||||
pub fn process_file_to(
|
||||
options: &AssetOptions,
|
||||
source: &Path,
|
||||
output_path: &Path,
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -13,20 +13,20 @@ mod image;
|
||||
mod js;
|
||||
mod json;
|
||||
|
||||
pub(crate) use file::process_file_to;
|
||||
pub use file::process_file_to;
|
||||
|
||||
/// A manifest of all assets collected from dependencies
|
||||
///
|
||||
/// This will be filled in primarily by incremental compilation artifacts.
|
||||
#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize)]
|
||||
pub(crate) struct AssetManifest {
|
||||
pub struct AssetManifest {
|
||||
/// Map of bundled asset name to the asset itself
|
||||
pub(crate) assets: HashMap<PathBuf, BundledAsset>,
|
||||
pub assets: HashMap<PathBuf, BundledAsset>,
|
||||
}
|
||||
|
||||
impl AssetManifest {
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn load_from_file(path: &Path) -> anyhow::Result<Self> {
|
||||
pub fn load_from_file(path: &Path) -> anyhow::Result<Self> {
|
||||
let src = std::fs::read_to_string(path)?;
|
||||
|
||||
serde_json::from_str(&src)
|
||||
@@ -34,7 +34,7 @@ impl AssetManifest {
|
||||
}
|
||||
|
||||
/// Fill this manifest with a file object/rlib files, typically extracted from the linker intercepted
|
||||
pub(crate) fn add_from_object_path(&mut self, path: &Path) -> anyhow::Result<()> {
|
||||
pub fn add_from_object_path(&mut self, path: &Path) -> anyhow::Result<()> {
|
||||
let data = std::fs::read(path)?;
|
||||
|
||||
match path.extension().and_then(|ext| ext.to_str()) {
|
||||
+1
-70
@@ -20,6 +20,7 @@ dioxus-core = { workspace = true, features = ["serialize"] }
|
||||
dioxus-core-types = { workspace = true }
|
||||
dioxus-devtools-types = { workspace = true }
|
||||
dioxus-cli-config = { workspace = true }
|
||||
dioxus-cli-opt = { workspace = true }
|
||||
dioxus-fullstack = { workspace = true }
|
||||
dioxus-dx-wire-format = { workspace = true }
|
||||
|
||||
@@ -90,76 +91,6 @@ ignore = "0.4.22"
|
||||
env_logger = { workspace = true }
|
||||
const-serialize = { workspace = true, features = ["serde"] }
|
||||
|
||||
# Image compression/conversion
|
||||
# - JPEG
|
||||
mozjpeg = { version = "0.10.7", default-features = false, features = [
|
||||
"parallel",
|
||||
] }
|
||||
# - PNG
|
||||
imagequant = "4.2.0"
|
||||
png = "0.17.9"
|
||||
# Image format/conversion
|
||||
image = { version = "0.25", features = ["avif"] }
|
||||
|
||||
# CSS Minification
|
||||
lightningcss = "1.0.0-alpha.60"
|
||||
|
||||
# Js minification - swc has introduces minor versions with breaking changes in the past so we pin all of their crates
|
||||
swc = "=0.283.0"
|
||||
swc_allocator = { version = "=0.1.8", default-features = false }
|
||||
swc_atoms = { version = "=0.6.7", default-features = false }
|
||||
swc_cached = { version = "=0.3.20", default-features = false }
|
||||
swc_common = { version = "=0.37.5", default-features = false }
|
||||
swc_compiler_base = { version = "=0.19.0", default-features = false }
|
||||
swc_config = { version = "=0.1.15", default-features = false }
|
||||
swc_config_macro = { version = "=0.1.4", default-features = false }
|
||||
swc_ecma_ast = { version = "=0.118.2", default-features = false }
|
||||
swc_ecma_codegen = { version = "=0.155.1", default-features = false }
|
||||
swc_ecma_codegen_macros = { version = "=0.7.7", default-features = false }
|
||||
swc_ecma_compat_bugfixes = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_common = { version = "=0.11.0", default-features = false }
|
||||
swc_ecma_compat_es2015 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2016 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2017 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2018 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2019 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2020 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2021 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es2022 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_compat_es3 = { version = "=0.12.0", default-features = false }
|
||||
swc_ecma_ext_transforms = { version = "=0.120.0", default-features = false }
|
||||
swc_ecma_lints = { version = "=0.100.0", default-features = false }
|
||||
swc_ecma_loader = { version = "=0.49.1", default-features = false }
|
||||
swc_ecma_minifier = { version = "=0.204.0", default-features = false }
|
||||
swc_ecma_parser = { version = "=0.149.1", default-features = false }
|
||||
swc_ecma_preset_env = { version = "=0.217.0", default-features = false, features = [
|
||||
"serde",
|
||||
] }
|
||||
swc_ecma_transforms = { version = "=0.239.0", default-features = false }
|
||||
swc_ecma_transforms_base = { version = "=0.145.0", default-features = false }
|
||||
swc_ecma_transforms_classes = { version = "=0.134.0", default-features = false }
|
||||
swc_ecma_transforms_compat = { version = "=0.171.0", default-features = false }
|
||||
swc_ecma_transforms_macros = { version = "=0.5.5", default-features = false }
|
||||
swc_ecma_transforms_module = { version = "=0.190.0", default-features = false }
|
||||
swc_ecma_transforms_optimization = { version = "=0.208.0", default-features = false }
|
||||
swc_ecma_transforms_proposal = { version = "=0.178.0", default-features = false }
|
||||
swc_ecma_transforms_react = { version = "=0.191.0", default-features = false }
|
||||
swc_ecma_transforms_typescript = { version = "=0.198.1", default-features = false }
|
||||
swc_ecma_usage_analyzer = { version = "=0.30.3", default-features = false }
|
||||
swc_ecma_utils = { version = "=0.134.2", default-features = false }
|
||||
swc_ecma_visit = { version = "=0.104.8", default-features = false }
|
||||
swc_eq_ignore_macros = { version = "=0.1.4", default-features = false }
|
||||
swc_error_reporters = { version = "=0.21.0", default-features = false }
|
||||
swc_fast_graph = { version = "=0.25.0", default-features = false }
|
||||
swc_macros_common = { version = "=0.3.13", default-features = false }
|
||||
swc_node_comments = { version = "=0.24.0", default-features = false }
|
||||
swc_timer = { version = "=0.25.0", default-features = false }
|
||||
swc_trace_macro = { version = "=0.1.3", default-features = false }
|
||||
swc_transform_common = { version = "=0.1.1", default-features = false }
|
||||
swc_typescript = { version = "=0.5.0", default-features = false }
|
||||
swc_visit = { version = "=0.6.2", default-features = false }
|
||||
browserslist-rs = { version = "=0.16.0" }
|
||||
|
||||
tracing-subscriber = { version = "0.3.18", features = ["std", "env-filter", "json"] }
|
||||
console-subscriber = { version = "0.3.0", optional = true }
|
||||
tracing = { workspace = true }
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use crate::assets::process_file_to;
|
||||
use crate::Result;
|
||||
use crate::{assets::AssetManifest, TraceSrc};
|
||||
use crate::{BuildRequest, Platform};
|
||||
use crate::{Result, TraceSrc};
|
||||
use anyhow::Context;
|
||||
use dioxus_cli_opt::{process_file_to, AssetManifest};
|
||||
use manganis_core::AssetOptions;
|
||||
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use super::{progress::ProgressTx, BuildArtifacts};
|
||||
use crate::dioxus_crate::DioxusCrate;
|
||||
use crate::Result;
|
||||
use crate::{assets::AssetManifest, TraceSrc};
|
||||
use crate::{link::LinkAction, BuildArgs};
|
||||
use crate::{AppBundle, Platform};
|
||||
use crate::{AppBundle, Platform, Result, TraceSrc};
|
||||
use anyhow::Context;
|
||||
use dioxus_cli_config::{APP_TITLE_ENV, ASSET_ROOT_ENV};
|
||||
use dioxus_cli_opt::AssetManifest;
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
@@ -46,7 +45,10 @@ impl BuildRequest {
|
||||
pub(crate) async fn build_all(self) -> Result<AppBundle> {
|
||||
tracing::debug!("Running build command...");
|
||||
|
||||
let (app, server) = self.build_concurrent().await?;
|
||||
let (app, server) = match self.build.force_sequential {
|
||||
true => self.build_sequential().await?,
|
||||
false => self.build_concurrent().await?,
|
||||
};
|
||||
|
||||
AppBundle::new(self, app, server).await
|
||||
}
|
||||
@@ -59,6 +61,12 @@ impl BuildRequest {
|
||||
Ok((app, server))
|
||||
}
|
||||
|
||||
async fn build_sequential(&self) -> Result<(BuildArtifacts, Option<BuildArtifacts>)> {
|
||||
let app = self.build_app().await?;
|
||||
let server = self.build_server().await?;
|
||||
Ok((app, server))
|
||||
}
|
||||
|
||||
pub(crate) async fn build_app(&self) -> Result<BuildArtifacts> {
|
||||
tracing::debug!("Building app...");
|
||||
|
||||
|
||||
+159
-157
@@ -223,191 +223,193 @@ fn remove_triple_newlines(string: &str) -> String {
|
||||
new_string
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use escargot::{CargoBuild, CargoRun};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::fs::{create_dir_all, read_to_string};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use tempfile::tempdir;
|
||||
use toml::Value;
|
||||
// todo: re-enable these tests with better parallelization
|
||||
//
|
||||
// #[cfg(test)]
|
||||
// pub(crate) mod tests {
|
||||
// use escargot::{CargoBuild, CargoRun};
|
||||
// use once_cell::sync::Lazy;
|
||||
// use std::fs::{create_dir_all, read_to_string};
|
||||
// use std::path::{Path, PathBuf};
|
||||
// use std::process::Command;
|
||||
// use tempfile::tempdir;
|
||||
// use toml::Value;
|
||||
|
||||
static BINARY: Lazy<CargoRun> = Lazy::new(|| {
|
||||
CargoBuild::new()
|
||||
.bin(env!("CARGO_BIN_NAME"))
|
||||
.current_release()
|
||||
.run()
|
||||
.expect("Couldn't build the binary for tests.")
|
||||
});
|
||||
// static BINARY: Lazy<CargoRun> = Lazy::new(|| {
|
||||
// CargoBuild::new()
|
||||
// .bin(env!("CARGO_BIN_NAME"))
|
||||
// .current_release()
|
||||
// .run()
|
||||
// .expect("Couldn't build the binary for tests.")
|
||||
// });
|
||||
|
||||
// Note: tests below (at least 6 of them) were written to mainly test
|
||||
// correctness of project's directory and its name, because previously it
|
||||
// was broken and tests bring a peace of mind. And also so that I don't have
|
||||
// to run my local hand-made tests every time.
|
||||
// // Note: tests below (at least 6 of them) were written to mainly test
|
||||
// // correctness of project's directory and its name, because previously it
|
||||
// // was broken and tests bring a peace of mind. And also so that I don't have
|
||||
// // to run my local hand-made tests every time.
|
||||
|
||||
pub(crate) type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
// pub(crate) type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
pub(crate) fn subcommand(name: &str) -> Command {
|
||||
let mut command = BINARY.command();
|
||||
command.arg(name).arg("--yes"); // Skip any questions by choosing default answers.
|
||||
command
|
||||
}
|
||||
// pub(crate) fn subcommand(name: &str) -> Command {
|
||||
// let mut command = BINARY.command();
|
||||
// command.arg(name).arg("--yes"); // Skip any questions by choosing default answers.
|
||||
// command
|
||||
// }
|
||||
|
||||
pub(crate) fn get_cargo_toml_path(project_path: &Path) -> PathBuf {
|
||||
project_path.join("Cargo.toml")
|
||||
}
|
||||
// pub(crate) fn get_cargo_toml_path(project_path: &Path) -> PathBuf {
|
||||
// project_path.join("Cargo.toml")
|
||||
// }
|
||||
|
||||
pub(crate) fn get_project_name(cargo_toml_path: &Path) -> Result<String> {
|
||||
Ok(toml::from_str::<Value>(&read_to_string(cargo_toml_path)?)?
|
||||
.get("package")
|
||||
.unwrap()
|
||||
.get("name")
|
||||
.unwrap()
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string())
|
||||
}
|
||||
// pub(crate) fn get_project_name(cargo_toml_path: &Path) -> Result<String> {
|
||||
// Ok(toml::from_str::<Value>(&read_to_string(cargo_toml_path)?)?
|
||||
// .get("package")
|
||||
// .unwrap()
|
||||
// .get("name")
|
||||
// .unwrap()
|
||||
// .as_str()
|
||||
// .unwrap()
|
||||
// .to_string())
|
||||
// }
|
||||
|
||||
fn subcommand_new() -> Command {
|
||||
subcommand("new")
|
||||
}
|
||||
// fn subcommand_new() -> Command {
|
||||
// subcommand("new")
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_new_with_dot_path() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = project_dir;
|
||||
// #[test]
|
||||
// fn test_subcommand_new_with_dot_path() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = project_dir;
|
||||
|
||||
let temp_dir = tempdir()?;
|
||||
// Make current dir's name deterministic.
|
||||
let current_dir = temp_dir.path().join(project_dir);
|
||||
create_dir_all(¤t_dir)?;
|
||||
let project_path = ¤t_dir;
|
||||
assert!(project_path.exists());
|
||||
// let temp_dir = tempdir()?;
|
||||
// // Make current dir's name deterministic.
|
||||
// let current_dir = temp_dir.path().join(project_dir);
|
||||
// create_dir_all(¤t_dir)?;
|
||||
// let project_path = ¤t_dir;
|
||||
// assert!(project_path.exists());
|
||||
|
||||
assert!(subcommand_new()
|
||||
.arg(".")
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_new()
|
||||
// .arg(".")
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_new_with_1_dir_path() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = project_dir;
|
||||
// #[test]
|
||||
// fn test_subcommand_new_with_1_dir_path() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = project_dir;
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_new()
|
||||
.arg(project_dir)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_new()
|
||||
// .arg(project_dir)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_new_with_2_dir_path() -> Result<()> {
|
||||
let project_dir = "a/b";
|
||||
let project_name = "b";
|
||||
// #[test]
|
||||
// fn test_subcommand_new_with_2_dir_path() -> Result<()> {
|
||||
// let project_dir = "a/b";
|
||||
// let project_name = "b";
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_new()
|
||||
.arg(project_dir)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_new()
|
||||
// .arg(project_dir)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_new_with_dot_path_and_custom_name() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = "project";
|
||||
// #[test]
|
||||
// fn test_subcommand_new_with_dot_path_and_custom_name() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = "project";
|
||||
|
||||
let temp_dir = tempdir()?;
|
||||
// Make current dir's name deterministic.
|
||||
let current_dir = temp_dir.path().join(project_dir);
|
||||
create_dir_all(¤t_dir)?;
|
||||
let project_path = ¤t_dir;
|
||||
assert!(project_path.exists());
|
||||
// let temp_dir = tempdir()?;
|
||||
// // Make current dir's name deterministic.
|
||||
// let current_dir = temp_dir.path().join(project_dir);
|
||||
// create_dir_all(¤t_dir)?;
|
||||
// let project_path = ¤t_dir;
|
||||
// assert!(project_path.exists());
|
||||
|
||||
assert!(subcommand_new()
|
||||
.arg("--name")
|
||||
.arg(project_name)
|
||||
.arg(".")
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_new()
|
||||
// .arg("--name")
|
||||
// .arg(project_name)
|
||||
// .arg(".")
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_new_with_1_dir_path_and_custom_name() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = "project";
|
||||
// #[test]
|
||||
// fn test_subcommand_new_with_1_dir_path_and_custom_name() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = "project";
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_new()
|
||||
.arg(project_dir)
|
||||
.arg("--name")
|
||||
.arg(project_name)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_new()
|
||||
// .arg(project_dir)
|
||||
// .arg("--name")
|
||||
// .arg(project_name)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_new_with_2_dir_path_and_custom_name() -> Result<()> {
|
||||
let project_dir = "a/b";
|
||||
let project_name = "project";
|
||||
// #[test]
|
||||
// fn test_subcommand_new_with_2_dir_path_and_custom_name() -> Result<()> {
|
||||
// let project_dir = "a/b";
|
||||
// let project_name = "project";
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_new()
|
||||
.arg(project_dir)
|
||||
.arg("--name")
|
||||
.arg(project_name)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_new()
|
||||
// .arg(project_dir)
|
||||
// .arg("--name")
|
||||
// .arg(project_name)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
// }
|
||||
+124
-122
@@ -78,152 +78,154 @@ impl Init {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{fs::create_dir_all, process::Command};
|
||||
use tempfile::tempdir;
|
||||
// todo: re-enable these tests with better parallelization
|
||||
//
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use std::{fs::create_dir_all, process::Command};
|
||||
// use tempfile::tempdir;
|
||||
|
||||
use super::create::tests::*;
|
||||
// use super::create::tests::*;
|
||||
|
||||
// Note: tests below (at least 6 of them) were written to mainly test
|
||||
// correctness of project's directory and its name, because previously it
|
||||
// was broken and tests bring a peace of mind. And also so that I don't have
|
||||
// to run my local hand-made tests every time.
|
||||
// // Note: tests below (at least 6 of them) were written to mainly test
|
||||
// // correctness of project's directory and its name, because previously it
|
||||
// // was broken and tests bring a peace of mind. And also so that I don't have
|
||||
// // to run my local hand-made tests every time.
|
||||
|
||||
fn subcommand_init() -> Command {
|
||||
subcommand("init")
|
||||
}
|
||||
// fn subcommand_init() -> Command {
|
||||
// subcommand("init")
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_init_with_default_path() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = project_dir;
|
||||
// #[test]
|
||||
// fn test_subcommand_init_with_default_path() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = project_dir;
|
||||
|
||||
let temp_dir = tempdir()?;
|
||||
// Make current dir's name deterministic.
|
||||
let current_dir = temp_dir.path().join(project_dir);
|
||||
create_dir_all(¤t_dir)?;
|
||||
let project_path = ¤t_dir;
|
||||
assert!(project_path.exists());
|
||||
// let temp_dir = tempdir()?;
|
||||
// // Make current dir's name deterministic.
|
||||
// let current_dir = temp_dir.path().join(project_dir);
|
||||
// create_dir_all(¤t_dir)?;
|
||||
// let project_path = ¤t_dir;
|
||||
// assert!(project_path.exists());
|
||||
|
||||
assert!(subcommand_init().current_dir(¤t_dir).status().is_ok());
|
||||
// assert!(subcommand_init().current_dir(¤t_dir).status().is_ok());
|
||||
|
||||
let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_init_with_1_dir_path() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = project_dir;
|
||||
// #[test]
|
||||
// fn test_subcommand_init_with_1_dir_path() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = project_dir;
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_init()
|
||||
.arg(project_dir)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_init()
|
||||
// .arg(project_dir)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_init_with_2_dir_path() -> Result<()> {
|
||||
let project_dir = "a/b";
|
||||
let project_name = "b";
|
||||
// #[test]
|
||||
// fn test_subcommand_init_with_2_dir_path() -> Result<()> {
|
||||
// let project_dir = "a/b";
|
||||
// let project_name = "b";
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_init()
|
||||
.arg(project_dir)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_init()
|
||||
// .arg(project_dir)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_init_with_default_path_and_custom_name() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = "project";
|
||||
// #[test]
|
||||
// fn test_subcommand_init_with_default_path_and_custom_name() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = "project";
|
||||
|
||||
let temp_dir = tempdir()?;
|
||||
// Make current dir's name deterministic.
|
||||
let current_dir = temp_dir.path().join(project_dir);
|
||||
create_dir_all(¤t_dir)?;
|
||||
let project_path = ¤t_dir;
|
||||
assert!(project_path.exists());
|
||||
// let temp_dir = tempdir()?;
|
||||
// // Make current dir's name deterministic.
|
||||
// let current_dir = temp_dir.path().join(project_dir);
|
||||
// create_dir_all(¤t_dir)?;
|
||||
// let project_path = ¤t_dir;
|
||||
// assert!(project_path.exists());
|
||||
|
||||
assert!(subcommand_init()
|
||||
.arg("--name")
|
||||
.arg(project_name)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_init()
|
||||
// .arg("--name")
|
||||
// .arg(project_name)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let cargo_toml_path = get_cargo_toml_path(project_path);
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_init_with_1_dir_path_and_custom_name() -> Result<()> {
|
||||
let project_dir = "dir";
|
||||
let project_name = "project";
|
||||
// #[test]
|
||||
// fn test_subcommand_init_with_1_dir_path_and_custom_name() -> Result<()> {
|
||||
// let project_dir = "dir";
|
||||
// let project_name = "project";
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_init()
|
||||
.arg(project_dir)
|
||||
.arg("--name")
|
||||
.arg(project_name)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_init()
|
||||
// .arg(project_dir)
|
||||
// .arg("--name")
|
||||
// .arg(project_name)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn test_subcommand_init_with_2_dir_path_and_custom_name() -> Result<()> {
|
||||
let project_dir = "a/b";
|
||||
let project_name = "project";
|
||||
// #[test]
|
||||
// fn test_subcommand_init_with_2_dir_path_and_custom_name() -> Result<()> {
|
||||
// let project_dir = "a/b";
|
||||
// let project_name = "project";
|
||||
|
||||
let current_dir = tempdir()?;
|
||||
// let current_dir = tempdir()?;
|
||||
|
||||
assert!(subcommand_init()
|
||||
.arg(project_dir)
|
||||
.arg("--name")
|
||||
.arg(project_name)
|
||||
.current_dir(¤t_dir)
|
||||
.status()
|
||||
.is_ok());
|
||||
// assert!(subcommand_init()
|
||||
// .arg(project_dir)
|
||||
// .arg("--name")
|
||||
// .arg(project_name)
|
||||
// .current_dir(¤t_dir)
|
||||
// .status()
|
||||
// .is_ok());
|
||||
|
||||
let project_path = current_dir.path().join(project_dir);
|
||||
let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
assert!(project_path.exists());
|
||||
assert!(cargo_toml_path.exists());
|
||||
assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
// let project_path = current_dir.path().join(project_dir);
|
||||
// let cargo_toml_path = get_cargo_toml_path(&project_path);
|
||||
// assert!(project_path.exists());
|
||||
// assert!(cargo_toml_path.exists());
|
||||
// assert_eq!(get_project_name(&cargo_toml_path)?, project_name);
|
||||
// Ok(())
|
||||
// }
|
||||
// }
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::assets::AssetManifest;
|
||||
use dioxus_cli_opt::AssetManifest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
mod assets;
|
||||
mod build;
|
||||
mod bundle_utils;
|
||||
mod cli;
|
||||
|
||||
@@ -10,9 +10,9 @@ homepage = "https://dioxuslabs.com/learn/0.5/getting_started"
|
||||
keywords = ["const", "serialize"]
|
||||
|
||||
[dependencies]
|
||||
syn = "2.0"
|
||||
quote = "1.0"
|
||||
proc-macro2 = "1.0.86"
|
||||
syn = { workspace = true }
|
||||
quote = { workspace = true }
|
||||
proc-macro2 = { workspace = true }
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
@@ -15,9 +15,9 @@ proc-macro = true
|
||||
# be careful with dependencies you add here - these need to get compiled for the proc macro and therefore
|
||||
# prevent the main code from compiling!
|
||||
[dependencies]
|
||||
proc-macro2 = { version = "1.0" }
|
||||
quote = "1.0"
|
||||
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
||||
proc-macro2 = { workspace = true }
|
||||
quote = { workspace = true }
|
||||
syn = { workspace = true, features = ["full", "extra-traits"] }
|
||||
manganis-core = { workspace = true }
|
||||
|
||||
[features]
|
||||
|
||||
Reference in new issue
Block a user