Use .node-version for pinning Node.js version (#6057)

Closes #6008: allowing Node.js to be used through Node version managers.
This commit is contained in:
Stijn ("stain") Seghers 2023-03-23 13:00:08 +01:00 committed by GitHub
parent de008eb2c2
commit 0bdf44cba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 14 deletions

1
.node-version Normal file
View File

@ -0,0 +1 @@
18.14.1

View File

@ -79,10 +79,10 @@ setup:
[the latest LTS version of node and npm](https://nodejs.org/en/download). Even
minor release changes are known to cause serious issues, thus **we provide
support for the latest LTS version only. Please do not report build issues if
you use other versions.** In case you run macOS or Linux the easiest way to
set up the proper version is by installing the
[Node Version Manager](https://github.com/nvm-sh/nvm) and running
`nvm install --lts && nvm use --lts`.
you use other versions.** The easiest way to set up the proper version is by
installing
[a Node version manager that automatically picks up the correct version](https://github.com/shadowspawn/node-version-usage#supporting-products),
like [fnm](https://github.com/Schniz/fnm).
- **(Optional) FlatBuffer compiler `flatc`**

View File

@ -3,8 +3,9 @@
wasm-size-limit: 15.50 MiB
required-versions:
# NB. The Rust version is pinned in rust-toolchain.toml.
# NB. The Node version is pinned in .node-version.
cargo-watch: ^8.1.1
node: =18.14.1
wasm-pack: ^0.10.2
# TODO [mwu]: Script can install `flatc` later on (if `conda` is present), so this is not required. However it should
# be required, if `conda` is missing.

View File

@ -7,8 +7,13 @@ use semver::VersionReq;
pub fn load_yaml(yaml_text: &str) -> Result<Config> {
let raw = serde_yaml::from_str::<ConfigRaw>(yaml_text)?;
/// Load the build configuration, based on the `build-config.yaml` and `.node-version` files in
/// the repo root.
pub fn load() -> Result<Config> {
let yaml_text = include_str!("../../../build-config.yaml");
let node_version = include_str!("../../../.node-version").trim();
let mut raw = serde_yaml::from_str::<ConfigRaw>(yaml_text)?;
raw.required_versions.insert("node".to_owned(), node_version.to_owned());
raw.try_into()
}

View File

@ -6,16 +6,13 @@
use enso_build::prelude::*;
use enso_build::config::Config;
use enso_build::config::ConfigRaw;
use enso_build::config;
fn main() -> Result {
setup_logging()?;
trace!("Starting CLI driver, cwd is {}", ide_ci::env::current_dir()?.display());
let build_config_yaml = include_str!("../../../build-config.yaml");
let build_config_raw = serde_yaml::from_str::<ConfigRaw>(build_config_yaml)?;
let build_config = Config::try_from(build_config_raw)?;
let build_config = config::load()?;
enso_build_cli::lib_main(Some(build_config))
}

View File

@ -137,8 +137,10 @@ arising from unsupported configurations will not be fixed by the core team.
In order to build and run Enso you will need the following tools:
- [NodeJS](https://nodejs.org/) with the latest LTS version. We recommend using
[`nvm`](https://github.com/nvm-sh/nvm) for managing NodeJS installation.
- [NodeJS](https://nodejs.org/) with the latest LTS version. We recommend
installing
[a Node version manager that automatically picks up the correct version](https://github.com/shadowspawn/node-version-usage#supporting-products),
like [fnm](https://github.com/Schniz/fnm).
- [sbt](https://www.scala-sbt.org/) with the same version as specified in
[`project/build.properties`](../project/build.properties).
- [Maven](https://maven.apache.org/) with version at least 3.6.3.