From fd80566237323dddbd60baa1d7596a6cdd8ff2c7 Mon Sep 17 00:00:00 2001 From: Gustavo Perdomo Date: Mon, 9 Dec 2024 15:04:51 -0300 Subject: [PATCH] chore: added preinstall script (#1167) --- .github/workflows/ci.yml | 1 + package-lock.json | 1 + package.json | 3 ++- tools/scripts/preinstall.mjs | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tools/scripts/preinstall.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e8f35d2..1045c090 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: # This enables task distribution via Nx Cloud # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun + # Uncomment this line to enable task distribution - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build" # Cache node_modules diff --git a/package-lock.json b/package-lock.json index c904b84f..d03ffa00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "@nx-tools/source", "version": "0.0.0", + "hasInstallScript": true, "license": "MIT", "dependencies": { "@actions/exec": "1.1.1", diff --git a/package.json b/package.json index eea95602..6f6905d3 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "check-lock-files": "node ./tools/scripts/check-lock-files.mjs", "commit": "cz", - "prepare": "husky" + "prepare": "husky", + "preinstall": "node ./tools/scripts/preinstall.mjs" }, "private": true, "engines": { diff --git a/tools/scripts/preinstall.mjs b/tools/scripts/preinstall.mjs new file mode 100644 index 00000000..5bf028d5 --- /dev/null +++ b/tools/scripts/preinstall.mjs @@ -0,0 +1,17 @@ +/** + * This pre-install script will check that the necessary dependencies are installed + * Checks for: + * - Node 20+ + */ + +if (process.env.CI) { + process.exit(0); +} + +import { lt as semverLessThan } from 'semver'; + +// Check node version +if (semverLessThan(process.version, '18.12.0')) { + console.error('Please make sure that your installed Node version is greater than v20'); + process.exit(1); +}