Skip to content

Commit

Permalink
Add changes by @AMoo-Miki
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey V. Osipov <sipopo@yandex.ru>
  • Loading branch information
sipopo committed Dec 16, 2022
1 parent fec31f5 commit 4c030bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multi DataSource] Update MD data source documentation link ([#2693](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2693))
- [Save Object Aggregation View] Add extension point in saved object management to register namespaces and show filter ([#2656](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2656))
- [Save Object Aggregation View] Fix for export all after scroll count response changed in PR#2656 ([#2696](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2696))
- Ability to start OS Dashboards with a newer and compatible nodejs version ([#2091](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2091))

### 馃悰 Bug Fixes

Expand Down
35 changes: 23 additions & 12 deletions src/setup_node_env/node_version_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,32 @@ var rawRequiredVersion = (pkg && pkg.engines && pkg.engines.node) || null;
var requiredVersion = rawRequiredVersion ? 'v' + rawRequiredVersion : rawRequiredVersion;
var currentVersionMajorMinorPatch = currentVersion.match(/^v(\d+)\.(\d+)\.(\d+)/);
var requiredVersionMajorMinorPatch = requiredVersion.match(/^v(\d+)\.(\d+)\.(\d+)/);
var currentMinorPatch = currentVersionMajorMinorPatch[2].concat(
'.',
currentVersionMajorMinorPatch[3]
);
var requiredMinorPatch = requiredVersionMajorMinorPatch[2].concat(
'.',
requiredVersionMajorMinorPatch[3]
);

var version = {
current: {
major: currentVersionMajorMinorPatch[1],
minor: parseInt(currentVersionMajorMinorPatch[2], 10),
patch: parseInt(currentVersionMajorMinorPatch[3], 10),
},
required: {
major: requiredVersionMajorMinorPatch[1],
minor: parseInt(requiredVersionMajorMinorPatch[2], 10),
patch: parseInt(requiredVersionMajorMinorPatch[3], 10),
},
}

var isVersionValid =
currentVersionMajorMinorPatch[1] === requiredVersionMajorMinorPatch[1] &&
parseFloat(currentMinorPatch) >= parseFloat(requiredMinorPatch);
var isMinorValid = currentVersionMajorMinorPatch[2] === requiredVersionMajorMinorPatch[2];
version.current.major === version.required.major &&
version.current.minor === version.required.minor &&
version.current.patch >= version.required.patch;

var isMinorValid =
version.current.major === version.required.major &&
version.current.minor > version.required.minor;


// Validates current the NodeJS version compatibility when OpenSearch Dashboards starts.
if (!isVersionValid) {
if (!isVersionValid && !isMinorValid) {
var errorMessage =
`OpenSearch Dashboards was built with ${requiredVersion} and does not support the current Node.js version ${currentVersion}. ` +
`Please use Node.js ${requiredVersion} or a higher patch version.`;
Expand Down

0 comments on commit 4c030bf

Please sign in to comment.