mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Migrate to once_cell (#2750)
* Replace lazy_static with once_cell. * Migrate to clap v3, so 1 less lazy_static. * Convert with `.into()`.
This commit is contained in:
parent
54de041981
commit
6b89e21034
@ -11,10 +11,10 @@ rand = { version = "0.8", features = ["small_rng"] }
|
||||
yew = { path = "../../packages/yew" }
|
||||
yew-router = { path = "../../packages/yew-router" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
lazy_static = "1.4.0"
|
||||
gloo-timers = "0.2"
|
||||
wasm-logger = "0.2"
|
||||
instant = { version = "0.1", features = ["wasm-bindgen"] }
|
||||
once_cell = "1"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use lazy_static::lazy_static;
|
||||
use lipsum::MarkovChain;
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::distributions::Bernoulli;
|
||||
use rand::rngs::StdRng;
|
||||
use rand::seq::IteratorRandom;
|
||||
@ -9,13 +9,11 @@ const KEYWORDS: &str = include_str!("../data/keywords.txt");
|
||||
const SYLLABLES: &str = include_str!("../data/syllables.txt");
|
||||
const YEW_CONTENT: &str = include_str!("../data/yew.txt");
|
||||
|
||||
lazy_static! {
|
||||
static ref YEW_CHAIN: MarkovChain<'static> = {
|
||||
static YEW_CHAIN: Lazy<MarkovChain<'static>> = Lazy::new(|| {
|
||||
let mut chain = MarkovChain::new();
|
||||
chain.learn(YEW_CONTENT);
|
||||
chain
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
pub struct Generator {
|
||||
pub seed: u32,
|
||||
|
||||
@ -14,5 +14,5 @@ wasm-logger = "0.2"
|
||||
yew = { path = "../../packages/yew", features = ["csr"] }
|
||||
yew-router = { path = "../../packages/yew-router" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
lazy_static = "1.4.0"
|
||||
once_cell = "1"
|
||||
gloo-timers = "0.2"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use lazy_static::lazy_static;
|
||||
use lipsum::MarkovChain;
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::distributions::Bernoulli;
|
||||
use rand::rngs::SmallRng;
|
||||
use rand::seq::IteratorRandom;
|
||||
@ -9,13 +9,11 @@ const KEYWORDS: &str = include_str!("../data/keywords.txt");
|
||||
const SYLLABLES: &str = include_str!("../data/syllables.txt");
|
||||
const YEW_CONTENT: &str = include_str!("../data/yew.txt");
|
||||
|
||||
lazy_static! {
|
||||
static ref YEW_CHAIN: MarkovChain<'static> = {
|
||||
static YEW_CHAIN: Lazy<MarkovChain<'static>> = Lazy::new(|| {
|
||||
let mut chain = MarkovChain::new();
|
||||
chain.learn(YEW_CONTENT);
|
||||
chain
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
pub struct Generator {
|
||||
pub seed: u64,
|
||||
|
||||
@ -17,7 +17,6 @@ proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
boolinator = "2"
|
||||
lazy_static = "1"
|
||||
proc-macro-error = "1"
|
||||
proc-macro2 = "1"
|
||||
quote = "1"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
use syn::parse::{Parse, ParseStream};
|
||||
use syn::{Expr, ExprTuple};
|
||||
|
||||
@ -64,9 +64,8 @@ impl Parse for ElementProps {
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref BOOLEAN_SET: HashSet<&'static str> = {
|
||||
vec![
|
||||
static BOOLEAN_SET: Lazy<HashSet<&'static str>> = Lazy::new(|| {
|
||||
[
|
||||
// Living Standard
|
||||
// From: https://html.spec.whatwg.org/#attributes-3
|
||||
// where `Value` = Boolean attribute
|
||||
@ -96,14 +95,11 @@ lazy_static! {
|
||||
"selected",
|
||||
"truespeed",
|
||||
]
|
||||
.into_iter()
|
||||
.collect()
|
||||
};
|
||||
}
|
||||
.into()
|
||||
});
|
||||
|
||||
lazy_static! {
|
||||
static ref LISTENER_SET: HashSet<&'static str> = {
|
||||
vec![
|
||||
static LISTENER_SET: Lazy<HashSet<&'static str>> = Lazy::new(|| {
|
||||
[
|
||||
// Living Standard
|
||||
// From: https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers
|
||||
"onabort",
|
||||
@ -173,13 +169,11 @@ lazy_static! {
|
||||
"onvolumechange",
|
||||
"onwaiting",
|
||||
"onwheel",
|
||||
|
||||
// Standard HTML Document and Element
|
||||
// From: https://html.spec.whatwg.org/multipage/webappapis.html#documentandelementeventhandlers
|
||||
"oncopy",
|
||||
"oncut",
|
||||
"onpaste",
|
||||
|
||||
// Others
|
||||
// From: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers
|
||||
"onanimationcancel",
|
||||
@ -211,7 +205,5 @@ lazy_static! {
|
||||
"ontransitionrun",
|
||||
"ontransitionstart",
|
||||
]
|
||||
.into_iter()
|
||||
.collect()
|
||||
};
|
||||
}
|
||||
.into()
|
||||
});
|
||||
|
||||
@ -13,7 +13,7 @@ git2 = "=0.14.2" # see https://github.com/rust-lang/git2-rs/issues/838 fixed wit
|
||||
regex = "1"
|
||||
reqwest = { version = "0.11", features = ["blocking", "json"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
structopt = "0.3"
|
||||
strum = { version = "0.24", features = ["derive"] }
|
||||
lazy_static = "1.4.0"
|
||||
clap = { version = "3", features = ["derive"] }
|
||||
semver = "1.0"
|
||||
once_cell = "1"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use anyhow::{bail, Result};
|
||||
use clap::Parser;
|
||||
use semver::Version;
|
||||
use structopt::StructOpt;
|
||||
|
||||
use crate::create_log_lines::create_log_lines;
|
||||
use crate::get_latest_version::get_latest_version;
|
||||
@ -11,7 +11,7 @@ use crate::write_log_lines::write_log_lines;
|
||||
use crate::write_version_changelog::write_changelog_file;
|
||||
use crate::yew_package::YewPackage;
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Cli {
|
||||
/// package to generate changelog for
|
||||
pub package: YewPackage,
|
||||
@ -23,23 +23,23 @@ pub struct Cli {
|
||||
pub from: Option<String>,
|
||||
|
||||
/// To commit. (ex. commit hash or for tags "refs/tags/yew-v0.19.3")
|
||||
#[structopt(short = "r", long, default_value = "HEAD")]
|
||||
#[clap(short = 'r', long, default_value = "HEAD")]
|
||||
pub to: String,
|
||||
|
||||
/// Path to changelog file
|
||||
#[structopt(short = "f", long, default_value = "CHANGELOG.md")]
|
||||
#[clap(short = 'f', long, default_value = "CHANGELOG.md")]
|
||||
pub changelog_path: String,
|
||||
|
||||
/// Skip writing changelog file
|
||||
#[structopt(short, long)]
|
||||
#[clap(short, long)]
|
||||
pub skip_file_write: bool,
|
||||
|
||||
/// Skip getting the next version
|
||||
#[structopt(short = "b", long)]
|
||||
#[clap(short = 'b', long)]
|
||||
pub skip_get_bump_version: bool,
|
||||
|
||||
/// Github token
|
||||
#[structopt(short = "t", long)]
|
||||
#[clap(short = 't', long)]
|
||||
pub token: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@ -2,19 +2,18 @@ use std::sync::Mutex;
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use git2::{Error, Oid, Repository};
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::github_issue_labels_fetcher::GitHubIssueLabelsFetcher;
|
||||
use crate::github_user_fetcher::GitHubUsersFetcher;
|
||||
use crate::log_line::LogLine;
|
||||
|
||||
lazy_static! {
|
||||
static ref REGEX_FOR_ISSUE_ID_CAPTURE: Regex = Regex::new(r"\s*\(#(\d+)\)").unwrap();
|
||||
static ref GITHUB_USERS_FETCHER: Mutex<GitHubUsersFetcher> = Default::default();
|
||||
static ref GITHUB_ISSUE_LABELS_FETCHER: Mutex<GitHubIssueLabelsFetcher> = Default::default();
|
||||
static ref PACKAGE_LABELS: Vec<String> = vec![];
|
||||
}
|
||||
static REGEX_FOR_ISSUE_ID_CAPTURE: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"\s*\(#(\d+)\)").unwrap());
|
||||
static GITHUB_USERS_FETCHER: Lazy<Mutex<GitHubUsersFetcher>> = Lazy::new(Default::default);
|
||||
static GITHUB_ISSUE_LABELS_FETCHER: Lazy<Mutex<GitHubIssueLabelsFetcher>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
pub fn create_log_line(
|
||||
repo: &Repository,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use changelog::Cli;
|
||||
use structopt::StructOpt;
|
||||
use clap::Parser;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
Cli::from_args().run()
|
||||
Cli::parse().run()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user