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 josh/dev-https
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper authored Aug 12, 2020
2 parents b793658 + ad32c7b commit ad9bf05
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 38 deletions.
67 changes: 42 additions & 25 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ billboard = "0.1.0"
binary-install = "0.0.3-alpha.1"
chrome-devtools-rs = { version = "0.0.0-alpha.1", features = ["color"] }
chrono = "0.4.13"
clap = "2.33.1"
clap = "2.33.2"
cloudflare = "0.6.6"
config = "0.10.1"
console = "0.11.3"
console = "0.12.0"
dirs = "3.0.1"
env_logger = "0.7.1"
eventual = "0.1.7"
Expand Down
3 changes: 2 additions & 1 deletion src/commands/whoami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub fn whoami(user: &GlobalUser) -> Result<(), failure::Error> {
let mut msg = format!("{} You are logged in with {}!\n", emoji::WAVING, auth);
let num_permissions_missing = missing_permissions.len();
if num_permissions_missing > 0 {
let login_msg = styles::highlight("`wrangler login`");
let config_msg = styles::highlight("`wrangler config`");
let whoami_msg = styles::highlight("`wrangler whoami`");
if missing_permissions.len() == 1 {
Expand All @@ -49,7 +50,7 @@ pub fn whoami(user: &GlobalUser) -> Result<(), failure::Error> {
styles::highlight(missing_permissions.get(1).unwrap())
));
}
msg.push_str(&format!("\n\nPlease generate a new token and authenticate with {}\nfor more information when running {}", config_msg, whoami_msg));
msg.push_str(&format!("\n\nPlease generate a new token and authenticate with {} or {}\nfor more information when running {}", login_msg, config_msg, whoami_msg));
}
message::billboard(&msg);
if table.len() > 1 {
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ fn run() -> Result<(), failure::Error> {

let not_recommended_msg = styles::warning("(Not Recommended)");
let recommended_cmd_msg = styles::highlight("`wrangler config --api-key`");
let wrangler_login_msg = styles::highlight("`wrangler login`");
let api_token_url = styles::url("https://dash.cloudflare.com/profile/api-tokens");
let token_support_url = styles::url(
"https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys",
Expand All @@ -648,7 +649,7 @@ fn run() -> Result<(), failure::Error> {

let user: GlobalUser = if default {
// API Tokens are the default
message::billboard(&format!("To find your API Token, go to {}\nand create it using the \"Edit Cloudflare Workers\" template.\n\nIf you are trying to use your Global API Key instead of an API Token\n{}, run {}.", api_token_url, not_recommended_msg, recommended_cmd_msg));
message::billboard(&format!("To find your API Token, go to {}\nand create it using the \"Edit Cloudflare Workers\" template.\n\nConsider using {} which only requires your Cloudflare username and password.\n\nIf you are trying to use your Global API Key instead of an API Token\n{}, run {}.", api_token_url, wrangler_login_msg, not_recommended_msg, recommended_cmd_msg));
let api_token: String = interactive::get_user_input("Enter API Token: ");
GlobalUser::TokenAuth { api_token }
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/preview/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ pub fn upload(
}
None => {
let wrangler_config_msg = styles::highlight("`wrangler config`");
let wrangler_login_msg = styles::highlight("`wrangler login`");
let docs_url_msg = styles::url("https://developers.cloudflare.com/workers/tooling/wrangler/configuration/#using-environment-variables");
message::billboard(
&format!("You have not provided your Cloudflare credentials.\n\nPlease run {} or visit\n{}\nfor info on authenticating with environment variables.", wrangler_config_msg, docs_url_msg)
&format!("You have not provided your Cloudflare credentials.\n\nPlease run {}, {}, or visit\n{}\nfor info on authenticating with environment variables.", wrangler_login_msg, wrangler_config_msg, docs_url_msg)
);

message::info("Running preview without authentication.");
Expand Down
6 changes: 4 additions & 2 deletions src/settings/global_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl GlobalUser {
s.merge(config::File::with_name(config_str))?;
} else {
failure::bail!(
"config path does not exist {}. Try running `wrangler config`",
"config path does not exist {}. Try running `wrangler login` or `wrangler config`",
config_str
);
}
Expand All @@ -103,11 +103,13 @@ impl GlobalUser {
match global_user {
Ok(user) => Ok(user),
Err(_) => {
let wrangler_login_msg = styles::highlight("`wrangler login`");
let wrangler_config_msg = styles::highlight("`wrangler config`");
let vars_msg = styles::url("https://developers.cloudflare.com/workers/tooling/wrangler/configuration/#using-environment-variables");
let msg = format!(
"{} Your authentication details are improperly configured.\nPlease run {} or visit\n{}\nfor info on configuring with environment variables",
"{} Your authentication details are improperly configured.\nPlease run {}, {}, or visit\n{}\nfor info on configuring with environment variables",
emoji::WARN,
wrangler_login_msg,
wrangler_config_msg,
vars_msg
);
Expand Down
21 changes: 16 additions & 5 deletions src/terminal/browser.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
use std::process::Command;
use std::process::{Command, Stdio};

pub fn open_browser(url: &str) -> Result<(), failure::Error> {
let _output = if cfg!(target_os = "windows") {
if cfg!(target_os = "windows") {
let url_escaped = url.replace("&", "^&");
let windows_cmd = format!("start {}", url_escaped);
Command::new("cmd").args(&["/C", &windows_cmd]).output()?
Command::new("cmd")
.args(&["/C", &windows_cmd])
.stdout(Stdio::null())
.spawn()?;
} else if cfg!(target_os = "linux") {
let linux_cmd = format!(r#"xdg-open "{}""#, url);
Command::new("sh").arg("-c").arg(&linux_cmd).output()?
Command::new("sh")
.arg("-c")
.arg(&linux_cmd)
.stdout(Stdio::null())
.spawn()?;
} else {
let mac_cmd = format!(r#"open "{}""#, url);
Command::new("sh").arg("-c").arg(&mac_cmd).output()?
Command::new("sh")
.arg("-c")
.arg(&mac_cmd)
.stdout(Stdio::null())
.spawn()?;
};

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/upload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn error_msg(status: reqwest::StatusCode, text: String) -> String {
if text.contains("\"code\": 10034,") {
"You need to verify your account's email address before you can publish. You can do this by checking your email or logging in to https://dash.cloudflare.com.".to_string()
} else if text.contains("\"code\":10000,") {
"Your user configuration is invalid, please run wrangler config and enter a new set of credentials.".to_string()
"Your user configuration is invalid, please run wrangler login or wrangler config and enter a new set of credentials.".to_string()
} else {
format!("Something went wrong! Status: {}, Details {}", status, text)
}
Expand Down

0 comments on commit ad9bf05

Please sign in to comment.