From 550bca6458c7dcbad4607c79f4f2696a4e437cbe Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Sep 2024 09:58:30 +0200 Subject: [PATCH] Switch from askama to rinja (#879) --- Cargo.lock | 209 ++++++++++++++++++++++++++++++++++++++---------- Cargo.toml | 2 +- src/cmd/init.rs | 2 +- src/shell.rs | 4 +- 4 files changed, 172 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f99bfbe..7122045 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,19 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.2" @@ -71,45 +84,6 @@ version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" -[[package]] -name = "askama" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28" -dependencies = [ - "askama_derive", - "askama_escape", -] - -[[package]] -name = "askama_derive" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83" -dependencies = [ - "askama_parser", - "mime", - "mime_guess", - "proc-macro2", - "quote", - "syn 2.0.50", -] - -[[package]] -name = "askama_escape" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" - -[[package]] -name = "askama_parser" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0" -dependencies = [ - "nom", -] - [[package]] name = "assert_cmd" version = "2.0.14" @@ -125,6 +99,12 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + [[package]] name = "bincode" version = "1.3.3" @@ -327,6 +307,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heck" version = "0.4.1" @@ -351,6 +337,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "libc" version = "0.2.154" @@ -365,7 +357,7 @@ checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ "bitflags 2.4.2", "libc", - "redox_syscall", + "redox_syscall 0.4.1", ] [[package]] @@ -374,6 +366,16 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "memchr" version = "2.7.1" @@ -429,6 +431,18 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "once_map" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30c7f82d6d446dd295845094f3a76bcdc5e6183b66667334e169f019cd05e5a0" +dependencies = [ + "ahash", + "hashbrown", + "parking_lot", + "stable_deref_trait", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -460,6 +474,29 @@ dependencies = [ "syn 2.0.50", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.3", + "smallvec", + "windows-targets 0.52.0", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -563,6 +600,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.4.2", +] + [[package]] name = "redox_users" version = "0.4.4" @@ -609,6 +655,43 @@ version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" +[[package]] +name = "rinja" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf96e290b3578af4ca20699abca2b90d5aba9eeae4acd123fd83c8547165eb4" +dependencies = [ + "itoa", + "rinja_derive", +] + +[[package]] +name = "rinja_derive" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fa31df46c7a8c125cfe8ec5f0b1d2689b65d4652fd8de9bf0ac41d6e0ac68f3" +dependencies = [ + "memchr", + "mime", + "mime_guess", + "once_map", + "proc-macro2", + "quote", + "rinja_parser", + "rustc-hash", + "syn 2.0.50", +] + +[[package]] +name = "rinja_parser" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee3ef25da2517861878f58ecbd7b8ba6bebd5634fe1b4421df20d100fb75745" +dependencies = [ + "memchr", + "nom", +] + [[package]] name = "rstest" version = "0.18.2" @@ -648,6 +731,12 @@ dependencies = [ "syn 2.0.50", ] +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.0" @@ -670,6 +759,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "semver" version = "1.0.22" @@ -696,6 +791,18 @@ dependencies = [ "syn 2.0.50", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -961,12 +1068,31 @@ version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + [[package]] name = "zoxide" version = "0.9.4" dependencies = [ "anyhow", - "askama", "assert_cmd", "bincode", "clap", @@ -979,6 +1105,7 @@ dependencies = [ "glob", "nix", "ouroboros", + "rinja", "rstest", "rstest_reuse", "serde", diff --git a/Cargo.toml b/Cargo.toml index fd6ad9e..40fb7df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ maintenance = { status = "actively-developed" } [dependencies] anyhow = "1.0.32" -askama = { version = "0.12.0", default-features = false } bincode = "1.3.1" clap = { version = "4.3.0", features = ["derive"] } color-print = "0.3.4" @@ -26,6 +25,7 @@ dunce = "1.0.1" fastrand = "2.0.0" glob = "0.3.0" ouroboros = "0.18.3" +rinja = { version = "0.3.2", default-features = false } serde = { version = "1.0.116", features = ["derive"] } [target.'cfg(unix)'.dependencies] diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 60bad63..3f79ed6 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -1,7 +1,7 @@ use std::io::{self, Write}; use anyhow::{Context, Result}; -use askama::Template; +use rinja::Template; use crate::cmd::{Init, InitShell, Run}; use crate::config; diff --git a/src/shell.rs b/src/shell.rs index a50c184..742c6fd 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -10,7 +10,7 @@ pub struct Opts<'a> { macro_rules! make_template { ($name:ident, $path:expr) => { - #[derive(::std::fmt::Debug, ::askama::Template)] + #[derive(::std::fmt::Debug, ::rinja::Template)] #[template(path = $path)] pub struct $name<'a>(pub &'a self::Opts<'a>); @@ -35,8 +35,8 @@ make_template!(Zsh, "zsh.txt"); #[cfg(feature = "nix-dev")] #[cfg(test)] mod tests { - use askama::Template; use assert_cmd::Command; + use rinja::Template; use rstest::rstest; use rstest_reuse::{apply, template};