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

Commit

Permalink
Merge branch 'master' into avery/re-connect-socket
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed May 13, 2020
2 parents 05ed1a7 + f49a0bf commit 0394c28
Show file tree
Hide file tree
Showing 27 changed files with 145 additions and 117 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build = "build.rs"
atty = "0.2.14"
base64 = "0.10.1"
billboard = "0.1.0"
binary-install = "0.0.3-alpha"
binary-install = "0.0.3-alpha.1"
chrome-devtools-rs = { version = "0.0.0-alpha.0", features = ["color"] }
chrono = "0.4.9"
clap = "2.32.0"
Expand Down Expand Up @@ -44,6 +44,7 @@ prettytable-rs = "0.8.0"
rand = "0.6.5"
regex = "1"
reqwest = { version = "0.10.4", features = ["blocking", "json"] }
semver = "0.9.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.39"
serde_with = "1.3.1"
Expand Down
9 changes: 6 additions & 3 deletions src/commands/build/mod.rs β†’ src/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod wranglerjs;

use crate::settings::toml::{Target, TargetType};
use crate::terminal::message;
use crate::wranglerjs;
use crate::{commands, install};

use std::path::PathBuf;
Expand All @@ -15,7 +14,11 @@ pub fn build(target: &Target) -> Result<(), failure::Error> {
}
TargetType::Rust => {
let tool_name = "wasm-pack";
let binary_path = install::install(tool_name, "rustwasm")?.binary(tool_name)?;
let tool_author = "rustwasm";
let is_binary = true;
let version = install::get_latest_version(tool_name)?;
let binary_path =
install::install(tool_name, tool_author, is_binary, version)?.binary(tool_name)?;
let args = ["build", "--target", "no-modules"];

let command = command(&args, &binary_path);
Expand Down
17 changes: 17 additions & 0 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::path::Path;

use clap::ArgMatches;

use crate::build;
use crate::settings::toml::Manifest;

use super::DEFAULT_CONFIG_PATH;

pub fn run(matches: &ArgMatches) -> Result<(), failure::Error> {
log::info!("Getting project settings");
let config_path = Path::new(DEFAULT_CONFIG_PATH);
let manifest = Manifest::new(&config_path)?;
let env = matches.value_of("env");
let target = &manifest.get_target(env)?;
build(&target)
}
File renamed without changes.
4 changes: 2 additions & 2 deletions src/commands/dev/gcs/watch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::{mpsc, Arc, Mutex};

use crate::commands;
use crate::build;
use crate::commands::dev::gcs::setup::get_preview_id;
use crate::commands::dev::server_config::ServerConfig;

Expand All @@ -22,7 +22,7 @@ pub fn watch_for_changes(
while let Ok(_) = receiver.recv() {
let user = user.clone();
let target = target.clone();
commands::build(&target)?;
build(&target)?;

// acquire the lock so incoming requests are halted
// until the new script is ready for them
Expand Down
4 changes: 2 additions & 2 deletions src/commands/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod server_config;
mod socket;
use server_config::ServerConfig;

use crate::commands;
use crate::build;
use crate::settings::global_user::GlobalUser;
use crate::settings::toml::Target;
use crate::terminal::{message, styles};
Expand All @@ -24,7 +24,7 @@ pub fn dev(
print_alpha_warning_message();

// before serving requests we must first build the Worker
commands::build(&target)?;
build(&target)?;

// eventually we will have two modes - edge and gcs
// edge for authenticated users and gcs for unauthenticated
Expand Down
6 changes: 5 additions & 1 deletion src/commands/generate/mod.rs β†’ src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ pub fn generate(

pub fn run_generate(name: &str, template: &str) -> Result<(), failure::Error> {
let tool_name = "cargo-generate";
let binary_path = install::install(tool_name, "ashleygwilliams")?.binary(tool_name)?;
let tool_author = "ashleygwilliams";
let is_binary = true;
let version = install::get_latest_version(tool_name)?;
let binary_path =
install::install(tool_name, tool_author, is_binary, version)?.binary(tool_name)?;

let args = ["generate", "--git", template, "--name", name, "--force"];

Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process::Command;

pub mod build;
mod build;
pub mod config;
pub mod dev;
pub mod generate;
Expand All @@ -14,8 +14,8 @@ pub mod subdomain;
pub mod tail;
pub mod whoami;

pub use self::build::run as build;
pub use self::config::global_config;
pub use build::build;
pub use dev::dev;
pub use generate::generate;
pub use init::init;
Expand All @@ -28,6 +28,8 @@ pub use whoami::whoami;

use regex::Regex;

const DEFAULT_CONFIG_PATH: &str = "./wrangler.toml";

// Run the given command and return its stdout.
pub fn run(mut command: Command, command_name: &str) -> Result<(), failure::Error> {
log::info!("Running {:?}", command);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use log::info;
use url::Url;
use ws::{Sender, WebSocket};

use crate::commands;
use crate::build;
use crate::http;
use crate::settings::global_user::GlobalUser;
use crate::settings::toml::Target;
Expand All @@ -35,7 +35,7 @@ pub fn preview(
verbose: bool,
headless: bool,
) -> Result<(), failure::Error> {
commands::build(&target)?;
build(&target)?;

let sites_preview: bool = target.site.is_some();

Expand Down Expand Up @@ -168,7 +168,7 @@ fn watch_for_changes(
watch_and_build(&target, Some(tx))?;

while let Ok(_e) = rx.recv() {
commands::build(&target)?;
build(&target)?;

if let Ok(new_id) = upload(&mut target, user, sites_preview, verbose) {
let script_id = format!("{}", new_id);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/publish/mod.rs β†’ src/commands/publish.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use std::path::{Path, PathBuf};

use crate::commands;
use crate::build;
use crate::commands::kv;
use crate::commands::kv::bucket::{sync, upload_files};
use crate::commands::kv::bulk::delete::delete_bulk;
Expand All @@ -21,7 +21,7 @@ pub fn publish(
validate_target_required_fields_present(target)?;

// Build the script before uploading.
commands::build(&target)?;
build(&target)?;

if let Some(site_config) = &target.site {
let path = &site_config.bucket.clone();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0394c28

Please sign in to comment.