Repository: wasmerio/wasmer (language: rust)

Issue:
Runtime allows for names with ' . ', while backend do not
A small problem, and most likely a small fix: the runtime allows for setting up a project with a name which includes characters that the backend does not allow.

To reproduce:

1. `cd $(mktemp -d) && wasmer deploy --template=static-website`
2. Press enter a lot (use the temporary directory as project name)
3. Expect setup to fail due to having incorrect name


Discussion / hints:

Fix patch:
diff --git a/lib/cli/src/commands/app/create.rs b/lib/cli/src/commands/app/create.rs
index 1b97135fa52..1107c9c3a4d 100644
--- a/lib/cli/src/commands/app/create.rs
+++ b/lib/cli/src/commands/app/create.rs
@@ -174,7 +174,7 @@ impl CmdAppCreate {
             }),
         };
 
-        crate::utils::prompts::prompt_for_ident(
+        crate::utils::prompts::prompt_for_app_ident(
             "What should be the name of the app?",
             default_name.as_deref(),
         )
diff --git a/lib/cli/src/utils/prompts.rs b/lib/cli/src/utils/prompts.rs
index 7846477cfe1..2e2209f2ad7 100644
--- a/lib/cli/src/utils/prompts.rs
+++ b/lib/cli/src/utils/prompts.rs
@@ -23,6 +23,31 @@ pub fn prompt_for_ident(message: &str, default: Option<&str>) -> Result<String,
     }
 }
 
+/// Ask a user for an application name.
+///
+/// Will continue looping until the user provides a valid name that contains
+/// neither dots nor spaces. Returns an error if there are issues with
+/// the input interaction.
+pub fn prompt_for_app_ident(message: &str, default: Option<&str>) -> Result<String, anyhow::Error> {
+    loop {
+        let theme = ColorfulTheme::default();
+        let diag = dialoguer::Input::with_theme(&theme)
+            .with_prompt(message)
+            .with_initial_text(default.unwrap_or_default());
+
+        let raw: String = diag.interact_text()?;
+        let val = raw.trim();
+        if val.is_empty() {
+            continue;
+        }
+        if val.contains('.') || val.contains(' ') {
+            eprintln!("The name must not contain dots or spaces. Please try again.");
+            continue;
+        }
+        return Ok(val.to_string());
+    }
+}
+
 /// Ask a user for a package name.
 ///
 /// Will continue looping until the user provides a valid name.


Test patch: