diff --git a/lib/cli/src/commands/app/create.rs b/lib/cli/src/commands/app/create.rs index 5a6668a4290..ee945b05678 100644 --- a/lib/cli/src/commands/app/create.rs +++ b/lib/cli/src/commands/app/create.rs @@ -454,10 +454,20 @@ impl CmdAppCreate { if app_yaml_path.exists() && app_yaml_path.is_file() { let contents = tokio::fs::read_to_string(&app_yaml_path).await?; - let contents = format!("{contents}\nname: {app_name}"); - let mut app_config = AppConfigV1::parse_yaml(&contents)?; - app_config.owner = Some(owner.to_string()); - let raw_app = serde_yaml::to_string(&app_config)?; + let mut raw_yaml: serde_yaml::Value = serde_yaml::from_str(&contents)?; + + if let serde_yaml::Value::Mapping(m) = &mut raw_yaml { + m.insert("name".into(), app_name.into()); + m.insert("owner".into(), owner.into()); + m.shift_remove("domains"); + m.shift_remove("app_id"); + }; + + let raw_app = serde_yaml::to_string(&raw_yaml)?; + + // Validate.. + AppConfigV1::parse_yaml(&raw_app)?; + tokio::fs::write(&app_yaml_path, raw_app).await?; }