Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Disallow templates with generate site #789

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,21 @@ fn run() -> Result<(), failure::Error> {
} else if let Some(matches) = matches.subcommand_matches("generate") {
let name = matches.value_of("name").unwrap_or("worker");
let site = matches.is_present("site");
let template = matches.value_of("template");
let mut target_type = None;

let template = if site {
if template.is_some() {
failure::bail!("You cannot pass a template and the --site flag to wrangler generate. If you'd like to use the default site boilerplate, run wrangler generate --site. If you'd like to use another site boilerplate, omit --site when running wrangler generate.")
}
"https://github.com/cloudflare/worker-sites-template"
} else {
if let Some(type_value) = matches.value_of("type") {
target_type = Some(TargetType::from_str(&type_value.to_lowercase())?);
}

let default_template = "https://github.com/cloudflare/worker-template";
matches.value_of("template").unwrap_or(match target_type {
let template = template.unwrap_or(match target_type {
Some(ref pt) => match pt {
TargetType::Rust => "https://github.com/cloudflare/rustwasm-worker-template",
_ => default_template,
Expand Down