diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2021-03-26 12:34:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-26 12:34:25 -0400 |
commit | f46e39c5c5435696daab9df075482e6e5c83533b (patch) | |
tree | 7699e06977e1149b5d056739f981c0217a91ed5e /cli | |
parent | 6c6f3e87c1a60bc96d006812a670212eeacd1257 (diff) |
remove macro_use (#9884)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/auth_tokens.rs | 2 | ||||
-rw-r--r-- | cli/colors.rs | 5 | ||||
-rw-r--r-- | cli/diagnostics.rs | 2 | ||||
-rw-r--r-- | cli/file_fetcher.rs | 5 | ||||
-rw-r--r-- | cli/file_watcher.rs | 1 | ||||
-rw-r--r-- | cli/flags.rs | 31 | ||||
-rw-r--r-- | cli/http_cache.rs | 10 | ||||
-rw-r--r-- | cli/http_util.rs | 1 | ||||
-rw-r--r-- | cli/import_map.rs | 2 | ||||
-rw-r--r-- | cli/lockfile.rs | 1 | ||||
-rw-r--r-- | cli/lsp/analysis.rs | 2 | ||||
-rw-r--r-- | cli/lsp/diagnostics.rs | 1 | ||||
-rw-r--r-- | cli/lsp/language_server.rs | 5 | ||||
-rw-r--r-- | cli/lsp/tsc.rs | 1 | ||||
-rw-r--r-- | cli/main.rs | 7 | ||||
-rw-r--r-- | cli/main_runtime.rs | 3 | ||||
-rw-r--r-- | cli/module_graph.rs | 9 | ||||
-rw-r--r-- | cli/program_state.rs | 2 | ||||
-rw-r--r-- | cli/specifier_handler.rs | 1 | ||||
-rw-r--r-- | cli/tools/fmt.rs | 2 | ||||
-rw-r--r-- | cli/tools/installer.rs | 13 | ||||
-rw-r--r-- | cli/tools/lint.rs | 2 | ||||
-rw-r--r-- | cli/tools/upgrade.rs | 2 | ||||
-rw-r--r-- | cli/tsc.rs | 2 |
24 files changed, 63 insertions, 49 deletions
diff --git a/cli/auth_tokens.rs b/cli/auth_tokens.rs index 64f42fc5c..83c97e641 100644 --- a/cli/auth_tokens.rs +++ b/cli/auth_tokens.rs @@ -1,6 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use deno_core::ModuleSpecifier; +use log::debug; +use log::error; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/cli/colors.rs b/cli/colors.rs index 278c141b4..5eafef4d4 100644 --- a/cli/colors.rs +++ b/cli/colors.rs @@ -4,7 +4,6 @@ #![allow(dead_code)] use regex::Regex; -use std::env; use std::fmt; use std::io::Write; use termcolor::Color::{Ansi256, Black, Blue, Cyan, Green, Red, White, Yellow}; @@ -13,14 +12,14 @@ use termcolor::{Ansi, ColorSpec, WriteColor}; #[cfg(windows)] use termcolor::{BufferWriter, ColorChoice}; -lazy_static! { +lazy_static::lazy_static! { // STRIP_ANSI_RE and strip_ansi_codes are lifted from the "console" crate. // Copyright 2017 Armin Ronacher <armin.ronacher@active-4.com>. MIT License. static ref STRIP_ANSI_RE: Regex = Regex::new( r"[\x1b\x9b][\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]" ).unwrap(); static ref NO_COLOR: bool = { - env::var_os("NO_COLOR").is_some() + std::env::var_os("NO_COLOR").is_some() }; } diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 0ba1a23ae..4044614fc 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -63,7 +63,7 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "utimeSync", ]; -lazy_static! { +lazy_static::lazy_static! { static ref MSG_MISSING_PROPERTY_DENO: Regex = Regex::new(r#"Property '([^']+)' does not exist on type 'typeof Deno'"#) .unwrap(); diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 3803c93c9..1c97d7018 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -10,8 +10,6 @@ use crate::http_util::FetchOnceResult; use crate::media_type::MediaType; use crate::text_encoding; use crate::version::get_user_agent; -use deno_runtime::permissions::Permissions; - use deno_core::error::custom_error; use deno_core::error::generic_error; use deno_core::error::uri_error; @@ -20,6 +18,9 @@ use deno_core::futures; use deno_core::futures::future::FutureExt; use deno_core::ModuleSpecifier; use deno_runtime::deno_fetch::reqwest; +use deno_runtime::permissions::Permissions; +use log::debug; +use log::info; use std::collections::HashMap; use std::env; use std::fs; diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs index 7bc4dd7b7..651a3ee31 100644 --- a/cli/file_watcher.rs +++ b/cli/file_watcher.rs @@ -5,6 +5,7 @@ use deno_core::error::AnyError; use deno_core::futures::ready; use deno_core::futures::stream::{Stream, StreamExt}; use deno_core::futures::Future; +use log::info; use notify::event::Event as NotifyEvent; use notify::event::EventKind; use notify::Config; diff --git a/cli/flags.rs b/cli/flags.rs index 5ae2f9027..6edce35de 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -10,11 +10,27 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::url::Url; use deno_runtime::permissions::PermissionsOptions; +use log::debug; use log::Level; use std::net::SocketAddr; use std::path::PathBuf; use std::str::FromStr; +lazy_static::lazy_static! { + static ref LONG_VERSION: String = format!( + "{} ({}, {})\nv8 {}\ntypescript {}", + crate::version::deno(), + if crate::version::is_canary() { + "canary" + } else { + env!("PROFILE") + }, + env!("TARGET"), + deno_core::v8_version(), + crate::version::TYPESCRIPT + ); +} + #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub enum DenoSubcommand { Bundle { @@ -259,21 +275,6 @@ To evaluate code in the shell: deno eval \"console.log(30933 + 404)\" "; -lazy_static! { - static ref LONG_VERSION: String = format!( - "{} ({}, {})\nv8 {}\ntypescript {}", - crate::version::deno(), - if crate::version::is_canary() { - "canary" - } else { - env!("PROFILE") - }, - env!("TARGET"), - deno_core::v8_version(), - crate::version::TYPESCRIPT - ); -} - /// Main entry point for parsing deno's command line flags. pub fn flags_from_vec(args: Vec<String>) -> clap::Result<Flags> { let version = crate::version::deno(); diff --git a/cli/http_cache.rs b/cli/http_cache.rs index e703ca05a..7eff2b9be 100644 --- a/cli/http_cache.rs +++ b/cli/http_cache.rs @@ -1,9 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -/// This module is meant to eventually implement HTTP cache -/// as defined in RFC 7234 (https://tools.ietf.org/html/rfc7234). -/// Currently it's a very simplified version to fulfill Deno needs -/// at hand. +//! This module is meant to eventually implement HTTP cache +//! as defined in RFC 7234 (https://tools.ietf.org/html/rfc7234). +//! Currently it's a very simplified version to fulfill Deno needs +//! at hand. use crate::fs_util; use crate::http_util::HeadersMap; use deno_core::error::generic_error; @@ -12,6 +11,7 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::serde_json; use deno_core::url::Url; +use log::error; use std::fs; use std::fs::File; use std::io; diff --git a/cli/http_util.rs b/cli/http_util.rs index 69778a101..a199f20c8 100644 --- a/cli/http_util.rs +++ b/cli/http_util.rs @@ -15,6 +15,7 @@ use deno_runtime::deno_fetch::reqwest::header::USER_AGENT; use deno_runtime::deno_fetch::reqwest::redirect::Policy; use deno_runtime::deno_fetch::reqwest::Client; use deno_runtime::deno_fetch::reqwest::StatusCode; +use log::debug; use std::collections::HashMap; /// Create new instance of async reqwest::Client. This client supports diff --git a/cli/import_map.rs b/cli/import_map.rs index 487c0d879..d18633545 100644 --- a/cli/import_map.rs +++ b/cli/import_map.rs @@ -6,6 +6,8 @@ use deno_core::serde_json::Map; use deno_core::serde_json::Value; use deno_core::url::Url; use indexmap::IndexMap; +use log::debug; +use log::info; use std::cmp::Ordering; use std::collections::HashSet; use std::error::Error; diff --git a/cli/lockfile.rs b/cli/lockfile.rs index d3470145e..0b52f5ee7 100644 --- a/cli/lockfile.rs +++ b/cli/lockfile.rs @@ -2,6 +2,7 @@ use deno_core::serde_json; use deno_core::serde_json::json; +use log::debug; use std::collections::BTreeMap; use std::io::Result; use std::path::PathBuf; diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 3359fc666..103a9c810 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -28,7 +28,7 @@ use std::collections::HashMap; use std::fmt; use std::rc::Rc; -lazy_static! { +lazy_static::lazy_static! { /// Diagnostic error codes which actually are the same, and so when grouping /// fixes we treat them the same. static ref FIX_ALL_ERROR_CODES: HashMap<&'static str, &'static str> = diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index d4ec3d494..82a365649 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -15,6 +15,7 @@ use deno_core::error::AnyError; use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::ModuleSpecifier; +use log::error; use lspower::lsp; use lspower::Client; use std::collections::HashMap; diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 0dc9a95cb..74dcf2136 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -10,6 +10,9 @@ use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; use dprint_plugin_typescript as dprint; +use log::error; +use log::info; +use log::warn; use lspower::jsonrpc::Error as LspError; use lspower::jsonrpc::Result as LspResult; use lspower::lsp::request::*; @@ -55,7 +58,7 @@ use super::tsc::Assets; use super::tsc::TsServer; use super::urls; -lazy_static! { +lazy_static::lazy_static! { static ref ABSTRACT_MODIFIER: Regex = Regex::new(r"\babstract\b").unwrap(); static ref EXPORT_MODIFIER: Regex = Regex::new(r"\bexport\b").unwrap(); } diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index e6943472b..e3c094dfa 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -31,6 +31,7 @@ use deno_core::JsRuntime; use deno_core::ModuleSpecifier; use deno_core::OpFn; use deno_core::RuntimeOptions; +use log::warn; use lspower::lsp; use regex::Captures; use regex::Regex; diff --git a/cli/main.rs b/cli/main.rs index 99178b10a..6833665c1 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -2,11 +2,6 @@ #![deny(warnings)] -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; - mod ast; mod auth_tokens; mod checksum; @@ -70,6 +65,8 @@ use deno_runtime::web_worker::WebWorker; use deno_runtime::web_worker::WebWorkerOptions; use deno_runtime::worker::MainWorker; use deno_runtime::worker::WorkerOptions; +use log::debug; +use log::info; use log::Level; use log::LevelFilter; use std::env; diff --git a/cli/main_runtime.rs b/cli/main_runtime.rs index f6d20f67e..db3f9fd02 100644 --- a/cli/main_runtime.rs +++ b/cli/main_runtime.rs @@ -2,9 +2,6 @@ #![deny(warnings)] -#[macro_use] -extern crate lazy_static; - mod colors; mod standalone; mod tokio_util; diff --git a/cli/module_graph.rs b/cli/module_graph.rs index f70fc1c41..18cb3209c 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -1,5 +1,4 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::ast; use crate::ast::parse; use crate::ast::transpile_module; @@ -23,11 +22,10 @@ use crate::tsc; use crate::tsc_config::IgnoredCompilerOptions; use crate::tsc_config::TsConfig; use crate::version; -use deno_core::error::AnyError; - use deno_core::error::anyhow; use deno_core::error::custom_error; use deno_core::error::get_custom_error_class; +use deno_core::error::AnyError; use deno_core::error::Context; use deno_core::futures::stream::FuturesUnordered; use deno_core::futures::stream::StreamExt; @@ -41,6 +39,7 @@ use deno_core::serde_json::Value; use deno_core::ModuleResolutionError; use deno_core::ModuleSource; use deno_core::ModuleSpecifier; +use log::debug; use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; @@ -53,7 +52,7 @@ use std::sync::Arc; use std::sync::Mutex; use std::time::Instant; -lazy_static! { +lazy_static::lazy_static! { /// Matched the `@deno-types` pragma. static ref DENO_TYPES_RE: Regex = Regex::new(r#"(?i)^\s*@deno-types\s*=\s*(?:["']([^"']+)["']|(\S+))"#) @@ -846,7 +845,7 @@ impl Graph { // moved it out of here, we wouldn't know until after the check has already // happened, which isn't informative to the users. for specifier in &self.roots { - info!("{} {}", colors::green("Check"), specifier); + log::info!("{} {}", colors::green("Check"), specifier); } let root_names = self.get_root_names(!config.get_check_js())?; diff --git a/cli/program_state.rs b/cli/program_state.rs index ebe223ab0..f47dcf0e9 100644 --- a/cli/program_state.rs +++ b/cli/program_state.rs @@ -25,6 +25,8 @@ use deno_core::resolve_url; use deno_core::url::Url; use deno_core::ModuleSource; use deno_core::ModuleSpecifier; +use log::debug; +use log::warn; use std::collections::HashMap; use std::env; use std::fs::read; diff --git a/cli/specifier_handler.rs b/cli/specifier_handler.rs index d65474b7a..9f329819e 100644 --- a/cli/specifier_handler.rs +++ b/cli/specifier_handler.rs @@ -17,6 +17,7 @@ use deno_core::serde::Deserialize; use deno_core::serde::Serialize; use deno_core::serde_json; use deno_core::ModuleSpecifier; +use log::debug; use std::collections::HashMap; use std::env; use std::fmt; diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 1385f849a..91d730c44 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -16,6 +16,8 @@ use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::futures; use deno_core::futures::FutureExt; +use log::debug; +use log::info; use std::fs; use std::io::stdin; use std::io::stdout; diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index a616db7ef..7547437a3 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -1,23 +1,24 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - use crate::flags::Flags; use crate::fs_util::canonicalize_path; use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::url::Url; use log::Level; -use regex::{Regex, RegexBuilder}; +use regex::Regex; +use regex::RegexBuilder; use std::env; use std::fs; use std::fs::File; use std::io; use std::io::Write; -#[cfg(not(windows))] -use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::path::PathBuf; -lazy_static! { +#[cfg(not(windows))] +use std::os::unix::fs::PermissionsExt; + +lazy_static::lazy_static! { static ref EXEC_NAME_RE: Regex = RegexBuilder::new( r"^[a-z][\w-]*$" ).case_insensitive(true).build().unwrap(); @@ -337,7 +338,7 @@ mod tests { use std::sync::Mutex; use tempfile::TempDir; - lazy_static! { + lazy_static::lazy_static! { pub static ref ENV_LOCK: Mutex<()> = Mutex::new(()); } diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index 2f31c88d6..e2897b72e 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -19,6 +19,8 @@ use deno_lint::linter::Linter; use deno_lint::linter::LinterBuilder; use deno_lint::rules; use deno_lint::rules::LintRule; +use log::debug; +use log::info; use serde::Serialize; use std::fs; use std::io::{stdin, Read}; diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index e98ecf5ff..cdca80dc7 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -12,7 +12,7 @@ use std::path::PathBuf; use std::process::Command; use tempfile::TempDir; -lazy_static! { +lazy_static::lazy_static! { static ref ARCHIVE_NAME: String = format!("deno-{}.zip", env!("TARGET")); } diff --git a/cli/tsc.rs b/cli/tsc.rs index 3e38a6918..dd97cb6b7 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -55,7 +55,7 @@ macro_rules! inc { }; } -lazy_static! { +lazy_static::lazy_static! { /// Contains static assets that are not preloaded in the compiler snapshot. pub(crate) static ref STATIC_ASSETS: HashMap<&'static str, &'static str> = (&[ ("lib.dom.asynciterable.d.ts", inc!("lib.dom.asynciterable.d.ts")), |