import semver from 'semver';
import chalk from 'chalk';
import { packageJson } from '../../../lib/index.js';
const isNodeVersionCompliantWithRequirement = (gatheredFromEnvironment, requiredVersion) => !semver.satisfies(gatheredFromEnvironment, requiredVersion);
const getNodeReleaseFromCurrentProcess = () => process.release || {};
const isNodeLTS = release => release.lts;
const getNodeVersionFromCurrentProcess = () => process.version;
const requiredEngineFromPackageJson = () => packageJson.engines.node;
const checkNode = (logger, requiredNodeVersion = requiredEngineFromPackageJson(), currentNodeVersion = getNodeVersionFromCurrentProcess()) => {
    if (isNodeVersionCompliantWithRequirement(currentNodeVersion, requiredNodeVersion)) {
        logger.warn(`Your NodeJS version is too old (${currentNodeVersion}). You should use at least NodeJS ${chalk.bold(requiredNodeVersion)}`);
    }
    if (!isNodeLTS(getNodeReleaseFromCurrentProcess())) {
        logger.warn('Your Node version is not LTS (Long Term Support), use it at your own risk! Begcode does not support non-LTS releases, so if you encounter a bug, please use a LTS version first.');
    }
};
export default checkNode;
