Repository: denoland/deno
File: cli/tools/init/mod.rs (Rust)

Code before:
    info!("  {}", colors::gray("# Run the program"));
    info!("  deno run main.ts");
    info!("");
    info!(
      "  {}",
      colors::gray("# Run the program and watch for file changes")
    );
    info!("  deno task dev");
    info!("");
    info!("  {}", colors::gray("# Run the tests"));
    info!("  deno test");
  }
  Ok(())
}

pub async fn init_npm(name: &str, args: Vec<String>) -> Result<i32, AnyError> {
  let script_name = format!("npm:create-{}", name);

  fn print_manual_usage(script_name: &str, args: &[String]) -> i32 {
    log::info!("{}", cformat!("You can initialize project manually by running <u>deno run {} {}</> and applying desired permissions.", script_name, args.join(" ")));
    1
  }

  if std::io::stdin().is_terminal() {
    log::info!(
      cstr!("Deno requires <u>all permissions</> to create a new <g>{}</> project. Do you want to continue? <p(245)>[y/n]</>"),
      name
    );
    loop {
      let _ = std::io::stdout().write(b"> ");
      let _ = std::io::stdout().flush();
      let mut answer = String::new();
      if std::io::stdin().read_line(&mut answer).is_ok() {
        let answer = answer.trim().to_ascii_lowercase();
        if answer != "y" {
          return Ok(print_manual_usage(&script_name, &args));
        } else {
          break;
        }
      }
    }
  } else {
    return Ok(print_manual_usage(&script_name, &args));
  }

  let new_flags = Flags {
    permissions: PermissionFlags {
      allow_all: true,
      ..Default::default()
    },
    allow_scripts: PackagesAllowedScripts::All,

Review comment (security):
Maybe this could be more scary:

⚠️ Warning: Do you fully trust the `npm:create-vite` package? Deno will invoke code from it with all permissions. Use `--allow-read` to bypass this. 
do you want to continue? y/n

Code after:
    info!("");
    info!("  {}", colors::gray("# Publish to JSR (dry run)"));
    info!("  deno publish --dry-run");
  } else {
    info!("  {}", colors::gray("# Run the program"));
    info!("  deno run main.ts");
    info!("");
    info!(
      "  {}",
      colors::gray("# Run the program and watch for file changes")
    );
    info!("  deno task dev");
    info!("");
    info!("  {}", colors::gray("# Run the tests"));
    info!("  deno test");
  }
  Ok(0)
}

async fn init_npm(name: &str, args: Vec<String>) -> Result<i32, AnyError> {
  let script_name = format!("npm:create-{}", name);

  fn print_manual_usage(script_name: &str, args: &[String]) -> i32 {
    log::info!("{}", cformat!("You can initialize project manually by running <u>deno run {} {}</> and applying desired permissions.", script_name, args.join(" ")));
    1
  }

  if std::io::stdin().is_terminal() {
    log::info!(
      cstr!("⚠️ Do you fully trust <y>{}</> package? Deno will invoke code from it with all permissions. Do you want to continue? <p(245)>[y/n]</>"),
      script_name
    );
    loop {
      let _ = std::io::stdout().write(b"> ")?;
      std::io::stdout().flush()?;
      let mut answer = String::new();
      if std::io::stdin().read_line(&mut answer).is_ok() {
        let answer = answer.trim().to_ascii_lowercase();
        if answer != "y" {
          return Ok(print_manual_usage(&script_name, &args));
        } else {
          break;
        }
      }
    }
  } else {
    return Ok(print_manual_usage(&script_name, &args));
  }

  let new_flags = Flags {
    permissions: PermissionFlags {