diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cbd8efe55..8d60e43f7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -27,7 +27,7 @@ If the proposal includes new designs or bigger changes, please be prepared to di ### Prerequisites -- [Node.js](https://nodejs.org/) 10+ and [yarn](https://yarnpkg.com) 1.9.4 installed +- [Node.js](https://nodejs.org/) 18.10.0+ and [yarn](https://yarnpkg.com) 1+ installed ### Project structure diff --git a/commands/cli/lib/index.js b/commands/cli/lib/index.js index 86bad8fa5..860ebd8bf 100755 --- a/commands/cli/lib/index.js +++ b/commands/cli/lib/index.js @@ -1,11 +1,10 @@ #!/usr/bin/env node const yargs = require('yargs'); const importCwd = require('import-cwd'); +const checkNodeVersion = require('../utils/checkNodeVersion'); +const pkg = require('../package.json'); -// const build = require('@nebula.js/cli-build/command'); -// const create = require('@nebula.js/cli-create/command'); -// const serve = require('@nebula.js/cli-serve/command'); -// const sense = require('@nebula.js/cli-sense/command'); +checkNodeVersion(pkg); yargs.usage('nebula [options]'); diff --git a/commands/cli/package.json b/commands/cli/package.json index a037e100a..067f9c29f 100644 --- a/commands/cli/package.json +++ b/commands/cli/package.json @@ -15,6 +15,9 @@ "files": [ "lib" ], + "engines": { + "node": ">=18.10.0" + }, "bin": { "nebula": "lib/index.js" }, diff --git a/commands/cli/utils/checkNodeVersion.js b/commands/cli/utils/checkNodeVersion.js new file mode 100644 index 000000000..3e4ad7621 --- /dev/null +++ b/commands/cli/utils/checkNodeVersion.js @@ -0,0 +1,28 @@ +function checkNodeVersion(pkg) { + if (pkg.engines && pkg.engines.node) { + const minVersion = pkg.engines.node.replace('>=', ''); + const [minMajor, minMinor, minPatch] = minVersion.split('.').map(Number); + const currentVersion = process.versions.node; + const [currentMajor, currentMinor, currentPatch] = currentVersion.split('.').map(Number); + + let validVersion = true; + if (currentMajor < minMajor) { + validVersion = false; + } else if (currentMajor === minMajor) { + if (currentMinor < minMinor) { + validVersion = false; + } + if (currentMinor === minMinor && currentPatch < minPatch) { + validVersion = false; + } + } + + if (!validVersion) { + // eslint-disable-next-line no-console + console.error(`${pkg.name} requires NodeJS >= ${minVersion}, but you are using NodeJS ${currentVersion}.`); + process.exit(1); + } + } +} + +module.exports = checkNodeVersion; diff --git a/commands/create/templates/sn/none/_package.json b/commands/create/templates/sn/none/_package.json index 318c6e7e6..ef0f60c17 100644 --- a/commands/create/templates/sn/none/_package.json +++ b/commands/create/templates/sn/none/_package.json @@ -10,7 +10,7 @@ "keywords": ["qlik", "nebula", "stardust"], "files": ["dist"], "engines": { - "node": ">=18" + "node": ">=18.10.0" }, "main": "dist/<%= name %>.js", "module": "dist/<%= name %>.esm.js", diff --git a/commands/create/templates/sn/picasso/common/_package.json b/commands/create/templates/sn/picasso/common/_package.json index febe6fb22..276642e50 100644 --- a/commands/create/templates/sn/picasso/common/_package.json +++ b/commands/create/templates/sn/picasso/common/_package.json @@ -10,7 +10,7 @@ "keywords": ["qlik", "nebula", "stardust"], "files": ["dist"], "engines": { - "node": ">=18" + "node": ">=18.10.0" }, "main": "dist/<%= name %>.js", "module": "dist/<%= name %>.esm.js", diff --git a/commands/serve/package.json b/commands/serve/package.json index 7dd4d9e06..b28435c52 100644 --- a/commands/serve/package.json +++ b/commands/serve/package.json @@ -20,6 +20,9 @@ "dist", "lib" ], + "engines": { + "node": ">=18.10.0" + }, "scripts": { "build": "cross-env NODE_ENV=production DEFAULTS=true webpack --config ./lib/webpack.build.js", "build:dev": "cross-env NODE_ENV=development DEFAULTS=true webpack --config ./lib/webpack.build.js",