From 4f60b933342520724e90166c2da3340a7a4f7e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin?= <94377405+kevin-legion@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:44:14 -0500 Subject: [PATCH] Update dependencies and make the project compile, no code cleanup --- Cargo.lock | 206 +++++++++++++++++++++++++++++++++++--------------- Cargo.toml | 32 ++++---- rustfmt.toml | 1 - src/lib.rs | 27 ++----- src/main.rs | 58 +++++++------- src/render.rs | 6 +- src/repo.rs | 4 +- src/types.rs | 1 + 8 files changed, 205 insertions(+), 130 deletions(-) delete mode 100644 rustfmt.toml diff --git a/Cargo.lock b/Cargo.lock index bd47a7a..7d17c02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,21 +1,14 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi 0.3.9", + "memchr 0.1.11", ] [[package]] @@ -66,6 +59,17 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "cargo_toml" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f61f8437a6b96dfb0be4aad6b222e01d5681b1ceacac7251501389e169e219" +dependencies = [ + "serde", + "serde_derive", + "toml", +] + [[package]] name = "case" version = "1.0.0" @@ -93,19 +97,32 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi 0.3.9", +] + [[package]] name = "clap" -version = "2.33.3" +version = "3.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "08799f92c961c7a1cf0cc398a9073da99e21ce388b46372c37f3191f2f3eed3e" dependencies = [ - "ansi_term", "atty", "bitflags", + "indexmap", + "os_str_bytes", "strsim", + "termcolor", "textwrap", - "unicode-width", - "vec_map", "yaml-rust", ] @@ -116,7 +133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "329b012f8172800c7ba02414b726d8664c342e58de6b7adba0b90823544806fc" dependencies = [ "colored", - "dirs", + "dirs 3.0.2", ] [[package]] @@ -149,6 +166,15 @@ dependencies = [ "dirs-sys", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-sys" version = "0.3.6" @@ -198,9 +224,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.13.18" +version = "0.13.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b483c6c2145421099df1b4efd50e0f6205479a072199460eff852fa15e5603c7" +checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6" dependencies = [ "bitflags", "libc", @@ -211,14 +237,17 @@ dependencies = [ "url", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "heck" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" -dependencies = [ - "unicode-segmentation", -] +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" @@ -240,6 +269,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "jobserver" version = "0.1.22" @@ -267,15 +306,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.94" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d" [[package]] name = "libgit2-sys" -version = "0.12.19+1.1.0" +version = "0.12.26+1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f322155d574c8b9ebe991a04f6908bb49e68a79463338d24a43d6274cb6443e6" +checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" dependencies = [ "cc", "libc", @@ -311,6 +350,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + [[package]] name = "log" version = "0.4.14" @@ -335,6 +380,31 @@ dependencies = [ "libc", ] +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + [[package]] name = "openssl-probe" version = "0.1.2" @@ -354,6 +424,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr 2.4.1", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -379,11 +458,13 @@ dependencies = [ name = "project_init" version = "3.1.23" dependencies = [ + "cargo_toml", "case", + "chrono", "clap", "cli-setup", "colored", - "dirs", + "dirs 4.0.0", "git2", "heck", "rustache-lists", @@ -391,7 +472,6 @@ dependencies = [ "serde_derive", "tempdir", "text_io", - "time", "toml", ] @@ -467,7 +547,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" dependencies = [ "aho-corasick", - "memchr", + "memchr 0.1.11", "regex-syntax", "thread_local", "utf8-ranges", @@ -513,15 +593,15 @@ checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" [[package]] name = "serde" -version = "1.0.125" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -530,9 +610,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -555,20 +635,26 @@ dependencies = [ "remove_dir_all", ] +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + [[package]] name = "text_io" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090d2ee73ae8f01646d500fbb72f99f0b2aea174b7b15d58359bbdf083f73e6d" +checksum = "ee74b5019b48991b09803402aaf9e65a053b3993fe9d9c475ab67a395358ba76" [[package]] name = "textwrap" -version = "0.11.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" [[package]] name = "thread-id" @@ -641,18 +727,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" - -[[package]] -name = "unicode-width" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" - [[package]] name = "unicode-xid" version = "0.2.2" @@ -683,12 +757,6 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -723,6 +791,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -731,6 +808,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "yaml-rust" -version = "0.3.5" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] diff --git a/Cargo.toml b/Cargo.toml index 6ccaa74..3090ef9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,33 +4,35 @@ version = "3.1.23" authors = ["Vanessa McHale "] description = "Quickly initialize projects from a template." license-file = "LICENSE" -exclude = [ "./.gitignore" ] +exclude = ["./.gitignore"] readme = "README.md" repository = "https://github.com/vmchale/project-init" documentation = "https://github.com/vmchale/project-init#README" homepage = "https://github.com/vmchale/project-init" build = "build.rs" +edition = "2021" [build-dependencies] -cli-setup = "0.2" +cli-setup = "0.2.7" [profile.release] lto = true [dependencies] -heck = "0.3" -case = "1.0" -toml = "0.5" -colored = "2.0" -clap = {version = "2.29", features = ["yaml"]} -time = "0.1" -rustache-lists = "0.1.0" -serde_derive = "1.0" -serde = "1.0" -text_io = "<= 0.1.6" -git2 = "0.13" -tempdir = "0.3" -dirs = "3.0" +cargo_toml = "0.11.3" +case = "1.0.0" +chrono = "0.4.19" +clap = { version = "3.0.13", features = ["yaml"] } +colored = "2.0.0" +dirs = "4.0.0" +git2 = "0.13.25" +heck = "0.4.0" +rustache-lists = "0.1.2" +serde = "1.0.136" +serde_derive = "1.0.136" +tempdir = "0.3.7" +text_io = "0.1.9" +toml = "0.5.8" [[bin]] name = "pi" diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 44148a2..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -reorder_imports = true diff --git a/src/lib.rs b/src/lib.rs index 59a2344..f4b1491 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,30 +1,19 @@ //! This library provides the functions/structs/methods used by the main //! binary. They are included //! here in the hopes that they can be illuminating to users. -#![allow(clippy::too_many_arguments)] -#![allow(clippy::cognitive_complexity)] +// #![allow(clippy::too_many_arguments)] +// #![allow(clippy::cognitive_complexity)] -extern crate case; -extern crate clap; -extern crate colored; -extern crate git2; -extern crate heck; -extern crate rustache; -#[macro_use] -extern crate serde_derive; -extern crate tempdir; -extern crate time; -extern crate toml; - -use case::*; -use colored::*; -use heck::*; -use rustache::{HashBuilder, VecBuilder}; use std::fs; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::path::PathBuf; + +use case::*; +use colored::*; +use heck::ToLowerCamelCase; +use rustache::{HashBuilder, VecBuilder}; use toml::Value::Table; pub mod includes; @@ -232,7 +221,7 @@ pub fn init_helper( hash = hash .insert("project", name) .insert("Project", name.to_capitalized()) - .insert("ProjectCamelCase", name.to_camel_case()) + .insert("ProjectCamelCase", name.to_lower_camel_case()) .insert("year", year) .insert("name", author.name) .insert("version", version) diff --git a/src/main.rs b/src/main.rs index 409fcc7..b1caffb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,19 @@ //! Source file for the binary. -#[macro_use] -extern crate clap; -#[macro_use] -extern crate text_io; - -extern crate case; -extern crate colored; -extern crate dirs; -extern crate git2; -extern crate project_init; -extern crate rustache; -extern crate tempdir; -extern crate time; -extern crate toml; +use std::fs; +#[cfg(not(target_os = "windows"))] +use std::fs::set_permissions; +#[cfg(not(target_os = "windows"))] +use std::fs::File; +use std::path::Path; +use std::path::PathBuf; +use std::process::Command; + +use cargo_toml::Manifest; use case::*; +use chrono::Datelike; +use chrono::Utc; +use clap::load_yaml; use clap::{App, AppSettings}; use colored::*; use git2::Repository; @@ -22,14 +21,8 @@ use project_init::render::*; use project_init::types::*; use project_init::*; use rustache::*; -use std::fs; -use std::fs::set_permissions; -use std::fs::File; -use std::path::Path; -use std::path::PathBuf; -use std::process::Command; use tempdir::TempDir; -use time::strftime; +use text_io::read; #[cfg(not(target_os = "windows"))] use std::os::unix::fs::PermissionsExt; @@ -51,11 +44,17 @@ fn mk_executable>(_: P) -> () { #[allow(clippy::cognitive_complexity)] #[allow(clippy::print_literal)] fn main() { + let cargo_manifest = Manifest::from_path("./cargo.toml").unwrap(); + let version = match cargo_manifest.package { + Some(package) => package.version, + None => "unknown".to_string(), + }; + // command-line parser let yaml = load_yaml!("options-en.yml"); let matches = App::from_yaml(yaml) - .version(crate_version!()) - .set_term_width(80) + .version(&*version) + .term_width(80) .setting(AppSettings::SubcommandRequired) .get_matches(); @@ -83,14 +82,19 @@ fn main() { }; // get year - let now = time::now(); - let year = now.tm_year + 1900; - let current_date = strftime("%m-%d-%Y", &now).unwrap(); + let now = Utc::now(); + let year = now.year(); + let current_date = format!( + "{month}-{day}-{year}", + month = now.month0(), + day = now.day0(), + year = year + ); if let Some(x) = matches.subcommand_matches("update") { let force = x.is_present("force"); - println!("current version: {}", crate_version!()); + println!("current version: {}", version); let s = if force { "curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git vmchale/project-init --force" diff --git a/src/render.rs b/src/render.rs index 105ed9d..0f029d1 100644 --- a/src/render.rs +++ b/src/render.rs @@ -1,7 +1,5 @@ //! Module containing functions for rendering templates -extern crate rustache; -use self::rustache::*; use std::fs; use std::fs::File; use std::io::prelude::*; @@ -10,6 +8,8 @@ use std::io::Cursor; use std::os::unix::fs::PermissionsExt; use std::process::*; +use rustache::*; + /// Trait allowing us to create dirs/templates/files. pub trait Create { fn create_dirs(&self, name: &str) -> (); @@ -90,7 +90,7 @@ pub fn render_templates( if let Some(t) = templates_pre { // create Vec of paths to templates let templates: Vec = t - .into_iter() + .iter() .map(|file| { let mut p = project.to_string(); p.push('/'); diff --git a/src/repo.rs b/src/repo.rs index b36e0e0..fe13270 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1,7 +1,7 @@ -use colored::*; -use std; use std::process::Command; +use colored::*; + pub fn git_init(name: &str) { let mut cmd = "cd ".to_string(); cmd.push_str(name); diff --git a/src/types.rs b/src/types.rs index 3dd900a..26b7e4a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,6 @@ //! This module contains the structs for the configuration files. +use serde_derive::Deserialize; use toml::value::Value; /// Struct for the author. This is read from the global