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

Alewis/default site bucket #638

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::settings::target::{Manifest, TargetType};
use crate::settings::target::{Manifest, Site, TargetType};
use crate::{commands, install};
use std::path::PathBuf;
use std::process::Command;
Expand All @@ -14,7 +14,15 @@ pub fn generate(
let target_type = target_type.unwrap_or_else(|| get_target_type(template));
run_generate(name, template, &target_type)?;
let config_path = PathBuf::from("./").join(&name);
Manifest::generate(name.to_string(), target_type, config_path, site)?;
// TODO: this is tightly coupled to our site template. Need to remove once
// we refine our generate logic.
let generated_site = if site {
Some(Site::new("./public"))
} else {
None
};
Manifest::generate(name.to_string(), target_type, config_path, generated_site)?;

Ok(())
}

Expand Down
6 changes: 4 additions & 2 deletions src/commands/init.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::commands;
use crate::settings::target::{Manifest, TargetType};
use crate::settings::target::{Manifest, Site, TargetType};
use crate::terminal::message;
use std::path::{Path, PathBuf};

Expand All @@ -15,7 +15,9 @@ pub fn init(
let name = name.unwrap_or_else(|| &dirname);
let target_type = target_type.unwrap_or_default();
let config_path = PathBuf::from("./");
let manifest = Manifest::generate(name.to_string(), target_type, config_path, site)?;
let initialized_site = if site { Some(Site::default()) } else { None };
let manifest =
Manifest::generate(name.to_string(), target_type, config_path, initialized_site)?;
message::success("Succesfully created a `wrangler.toml`");

if site {
Expand Down
12 changes: 10 additions & 2 deletions src/settings/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ pub struct Site {
pub entry_point: Option<String>,
}

impl Site {
pub fn new(bucket: &str) -> Site {
let mut site = Site::default();
site.bucket = String::from(bucket);

site
}
}

impl Default for Site {
fn default() -> Site {
Site {
Expand Down Expand Up @@ -133,9 +142,8 @@ impl Manifest {
name: String,
target_type: TargetType,
config_path: PathBuf,
site: bool,
site: Option<Site>,
) -> Result<Manifest, failure::Error> {
let site = if site { Some(Site::default()) } else { None };
let manifest = Manifest {
account_id: String::new(),
env: None,
Expand Down