Rust library to generate static websites
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: misc init fixes

+29 -5
+29 -5
crates/cli/src/init.rs
··· 36 36 37 37 inquire::set_global_render_config(get_render_config()); 38 38 39 - // Run cargo info maudit in a tmp directory to avoid catching a local version 40 39 let cargo_search = std::process::Command::new("cargo") 41 40 .arg("search") 42 41 .arg("maudit") 43 42 .args(["--limit", "1"]) 43 + .current_dir(std::env::temp_dir()) // `cargo search` sometimes can fail in certain directories, so we use a temp dir 44 44 .output() 45 45 .expect("Failed to run cargo info maudit"); 46 46 ··· 88 88 }) 89 89 .with_validators(&[ 90 90 Box::new(|s: &str| { 91 + // Don't check if the directory already exists if the user wants to use the current directory 92 + if s == "." { 93 + return Ok(Validation::Valid); 94 + } 95 + 91 96 if std::path::Path::new(&s).exists() { 92 97 Ok(Validation::Invalid( 93 98 "A directory with this name already exists".into(), ··· 221 226 info!(name: "SKIP_FORMAT", "👑 {} {}! Next steps:", "Project created".bold(), "successfully".green().to_string().bold()); 222 227 println!(); 223 228 224 - info!(name: "SKIP_FORMAT", "1. Run {} to enter your project's directory.", format!("cd {}", project_path.display()).bold().bright_blue().underline()); 225 - info!(name: "SKIP_FORMAT", "2. Run {} to start the development server, {} to stop it.", "maudit dev".bold().bright_blue().underline(), "CTRL+C".bright_blue()); 229 + let enter_directory = if project_path != PathBuf::from(".") { 230 + format!( 231 + "1. Run {} to enter your project's directory.\n2. ", 232 + format!("cd {}", project_path.display()) 233 + .bold() 234 + .bright_blue() 235 + .underline() 236 + ) 237 + } else { 238 + " ".to_string() 239 + }; 240 + 241 + info!( 242 + name: "SKIP_FORMAT", 243 + "{}Run {} to start the development server, {} to stop it.", 244 + enter_directory, 245 + "maudit dev".bold().bright_blue().underline(), 246 + "CTRL+C".bright_blue() 247 + ); 226 248 println!(); 227 249 228 250 info!(name: "SKIP_FORMAT", " Visit {} for more information on using Maudit.", "https://maudit.org/docs".bold().bright_magenta().underline()); ··· 267 289 Ok(content) => { 268 290 let mut cargo_toml = content.parse::<DocumentMut>().expect("invalid doc"); 269 291 292 + let project_path = project_path 293 + .canonicalize() 294 + .expect("Failed to canonicalize project path"); 270 295 if let Some(project_name) = project_path.file_name().and_then(|name| name.to_str()) { 271 296 cargo_toml["package"]["name"] = toml_edit::value(project_name); 272 297 ··· 343 368 344 369 fn has_invalid_filepath_chars(s: &str) -> bool { 345 370 s.chars().any(|c| { 346 - c == '/' 347 - || c == '\\' 371 + c == '\\' 348 372 || c == ':' 349 373 || c == '*' 350 374 || c == '?'
crates/cli/src/init/template.rs

This is a binary file and will not be displayed.