@@ -12,13 +12,27 @@ import { RushConfiguration } from '../api/RushConfiguration';
1212 */
1313const UPCOMING_NODE_LTS_VERSION : number = 12 ;
1414const nodeVersion : string = process . versions . node ;
15+ const nodeMajorVersion : number = semver . major ( nodeVersion ) ;
1516
1617/**
1718 * This class provides useful functions for warning if the current Node.js runtime isn't supported.
1819 *
1920 * @internal
2021 */
2122export class NodeJsCompatibility {
23+ public static warnAboutCompatibilityIssues (
24+ alreadyReportedNodeTooNewError : boolean ,
25+ rushConfiguration : RushConfiguration | undefined
26+ ) : boolean {
27+ // Only show the first warning
28+ return (
29+ NodeJsCompatibility . warnAboutVersionTooOld ( ) ||
30+ NodeJsCompatibility . warnAboutVersionTooNew ( true , alreadyReportedNodeTooNewError ) ||
31+ NodeJsCompatibility . warnAboutOddNumberedVersion ( ) ||
32+ NodeJsCompatibility . warnAboutNonLtsVersion ( rushConfiguration )
33+ ) ;
34+ }
35+
2236 public static warnAboutVersionTooOld ( ) : boolean {
2337 if ( semver . satisfies ( nodeVersion , '< 8.9.0' ) ) {
2438 // We are on an ancient version of Node.js that is known not to work with Rush
@@ -33,12 +47,12 @@ export class NodeJsCompatibility {
3347 }
3448 }
3549
36- public static warnAboutVersionTooNew ( isRushLib : boolean ) : boolean {
37- if ( semver . satisfies ( nodeVersion , ` >= ${ UPCOMING_NODE_LTS_VERSION + 1 } .0.0` ) ) {
50+ public static warnAboutVersionTooNew ( isRushLib : boolean , alreadyReportedNodeTooNewError : boolean ) : boolean {
51+ if ( ! alreadyReportedNodeTooNewError && nodeMajorVersion >= ( UPCOMING_NODE_LTS_VERSION + 1 ) ) {
3852 // We are on a much newer release than we have tested and support
3953 if ( isRushLib ) {
4054 console . warn ( colors . yellow (
41- `Your version of Node.js (${ nodeVersion } ) has not been tested with this release` +
55+ `Your version of Node.js (${ nodeVersion } ) has not been tested with this release ` +
4256 `of the Rush engine. Please consider upgrading the "rushVersion" setting in rush.json, ` +
4357 `or downgrading Node.js.`
4458 ) ) ;
@@ -62,6 +76,19 @@ export class NodeJsCompatibility {
6276 ! rushConfiguration . suppressNodeLtsWarning &&
6377 ! NodeJsCompatibility . isLtsVersion
6478 ) {
79+ console . warn ( colors . yellow (
80+ `Your version of Node.js (${ nodeVersion } ) is not a Long-Term Support (LTS) release. ` +
81+ 'These versions frequently have bugs. Please consider installing a stable release.'
82+ ) ) ;
83+
84+ return true ;
85+ } else {
86+ return false ;
87+ }
88+ }
89+
90+ public static warnAboutOddNumberedVersion ( ) : boolean {
91+ if ( NodeJsCompatibility . isOddNumberedVersion ) {
6592 console . warn ( colors . yellow (
6693 `Your version of Node.js (${ nodeVersion } ) is an odd-numbered release. ` +
6794 `These releases frequently have bugs. Please consider installing a Long Term Support (LTS) ` +
@@ -83,4 +110,8 @@ export class NodeJsCompatibility {
83110
84111 return ! ! ( process as IExtendedNodeProcess ) . release . lts ;
85112 }
113+
114+ public static get isOddNumberedVersion ( ) : boolean {
115+ return ( nodeMajorVersion % 2 ) !== 0 ;
116+ }
86117}
0 commit comments