From bb64e1e787ed5130577b7470249bf5f9190474cf Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sat, 15 May 2021 10:26:04 +0200 Subject: [PATCH 1/2] build:(xtask): #1426: Allow a wider range of Node.js versions Introduce https://crates.io/crates/version-compare Allow Node.js version between 10.18.0 and 11.0.0 https://nodejs.org/en/download/releases/ --- Cargo.lock | 7 +++++++ rust-bins/xtask/Cargo.toml | 1 + rust-bins/xtask/src/main.rs | 24 +++++++++++++++--------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5c33ae95..4f388ac04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3412,6 +3412,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version-compare" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b" + [[package]] name = "version_check" version = "0.9.3" @@ -3568,6 +3574,7 @@ dependencies = [ "anyhow", "run_script", "structopt", + "version-compare", "version_check", ] diff --git a/rust-bins/xtask/Cargo.toml b/rust-bins/xtask/Cargo.toml index 461aea4f2..07f47486a 100644 --- a/rust-bins/xtask/Cargo.toml +++ b/rust-bins/xtask/Cargo.toml @@ -17,3 +17,4 @@ anyhow = "1.0.32" run_script = "0.6.3" structopt = "0.3.18" version_check = "0.9.2" +version-compare = "0.0.11" diff --git a/rust-bins/xtask/src/main.rs b/rust-bins/xtask/src/main.rs index bb1bbf3e0..ed7c83bc3 100644 --- a/rust-bins/xtask/src/main.rs +++ b/rust-bins/xtask/src/main.rs @@ -16,9 +16,12 @@ use anyhow::Result; use std::process::{Command, Output}; use structopt::StructOpt; +use version_compare::Version; const MIN_RUST_VERSION: &str = "1.51.0"; -const NODE_VERSION: &str = "10.22.1"; +const MIN_NODE_VERSION: &str = "10.18.0"; +const REC_NODE_VERSION: &str = "10.22.1"; +const MAX_NODE_VERSION: &str = "11.0.0"; #[derive(StructOpt)] struct DuniterXTask { @@ -54,18 +57,21 @@ fn main() -> Result<()> { if !args.skip_npm { println!("Check node version …"); - if exec_and_get_stdout(Command::new("node").arg("-v")) - .unwrap_or_default() - .trim_end() - != format!("v{}", NODE_VERSION) - { + let node_vers = exec_and_get_stdout(Command::new("node").arg("-v")).unwrap_or_default(); + let node_vers = node_vers.trim_end(); + let node_vers_cut = Version::from(&node_vers[1..]).unwrap(); + let min_node_vers = Version::from(MIN_NODE_VERSION).unwrap(); + let max_node_vers = Version::from(MAX_NODE_VERSION).unwrap(); + if node_vers_cut < min_node_vers || max_node_vers <= node_vers_cut { eprintln!( - "Duniter requires node v{} exactly. Please install node v{} (you can use nvm).", - NODE_VERSION, NODE_VERSION + "Duniter requires node between v{} and v{} excluded.\n\ + Please install a correct node version (you can use nvm).\n\ + Current version {}. Recommended version v{}", + MIN_NODE_VERSION, MAX_NODE_VERSION, node_vers, REC_NODE_VERSION ); std::process::exit(1); } else { - println!("Node v{} already installed ✔", NODE_VERSION); + println!("Node {} installed: Is a compatible version ✔", node_vers); } } match args.command { -- GitLab From 99a61588f41fc3ff812d96ad1ec04736f2679da8 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sat, 15 May 2021 10:48:15 +0200 Subject: [PATCH 2/2] doc(dev) Add precision to install gcc-c++ for Fedora Replace yum with dnf Fix markdown --- doc/dev/setup_env_dev.md | 4 ++-- doc/use/manual_compilation.md | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/dev/setup_env_dev.md b/doc/dev/setup_env_dev.md index 002b58f1d..9581cc8b1 100644 --- a/doc/dev/setup_env_dev.md +++ b/doc/dev/setup_env_dev.md @@ -23,7 +23,7 @@ cargo xtask build To develop on Duniter, there is currently the following requirement: - A computer with GNU/Linux or Mac as operating system -- Build essential tools +- Build essential tools: Amongs other: GCC C++ - wget - git (apt-get install git) - Rust @@ -48,7 +48,7 @@ echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> .bashrc ### Build the project -#### Clone the repository +#### Clone the repository ```bash git clone https://git.duniter.org/nodes/typescript/duniter diff --git a/doc/use/manual_compilation.md b/doc/use/manual_compilation.md index a0e045968..bfc60ca0d 100644 --- a/doc/use/manual_compilation.md +++ b/doc/use/manual_compilation.md @@ -61,8 +61,11 @@ Depend on your distribution: apt-get install build-essential cmake ##### Fedora +```bash +sudo dnf install gcc-c++ +``` - yum groupinstall "Development Tools" "Development Libraries" + dnf groupinstall "Development Tools" "Development Libraries" TODO: If you know how to install build essential tools for other gnu/linux distributions or for mac, you can complete this documentation and submit a merge request. -- GitLab