From c121d572156b3166653bb884e44651c633690d5b Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Wed, 23 Aug 2023 12:15:53 +0300 Subject: [PATCH] update: dev version check --- .../protocol/ProjectManagementApi.scala | 8 +++++--- .../requesthandler/ProjectServiceFailureMapper.scala | 4 ++-- .../service/ProjectServiceFailure.scala | 1 + .../RuntimeVersionManagerErrorRecoverySyntax.scala | 1 + .../enso/runtimeversionmanager/CurrentVersion.scala | 2 +- .../components/ComponentsException.scala | 4 +++- .../components/RuntimeVersionManager.scala | 12 ++++++++++-- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/protocol/ProjectManagementApi.scala b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/protocol/ProjectManagementApi.scala index 25a57335ce..a0f21a061c 100644 --- a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/protocol/ProjectManagementApi.scala +++ b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/protocol/ProjectManagementApi.scala @@ -261,11 +261,13 @@ object ProjectManagementApi { case class BrokenComponentError(msg: String) extends Error(4021, msg) - case class ProjectManagerUpgradeRequired(minimumRequiredVersion: SemVer) - extends Error( + case class ProjectManagerUpgradeRequired( + currentVersion: SemVer, + minimumRequiredVersion: SemVer + ) extends Error( 4022, s"Project manager $minimumRequiredVersion is required to install the " + - s"requested engine. Please upgrade." + s"requested engine. Current version is $currentVersion. Please upgrade." ) { /** Additional payload that can be used to get the version string of the diff --git a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/requesthandler/ProjectServiceFailureMapper.scala b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/requesthandler/ProjectServiceFailureMapper.scala index 2df912e7f1..65c3f25fa7 100644 --- a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/requesthandler/ProjectServiceFailureMapper.scala +++ b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/requesthandler/ProjectServiceFailureMapper.scala @@ -27,8 +27,8 @@ object ProjectServiceFailureMapper { case CannotRemoveOpenProject => CannotRemoveOpenProjectError case ProjectOperationTimeout => ServiceError case LanguageServerFailure(msg) => LanguageServerError(msg) - case ProjectManagerUpgradeRequiredFailure(version) => - ProjectManagerUpgradeRequired(version) + case ProjectManagerUpgradeRequiredFailure(current, required) => + ProjectManagerUpgradeRequired(current, required) case MissingComponentFailure(msg) => MissingComponentError(msg) case BrokenComponentFailure(msg) => BrokenComponentError(msg) case ComponentInstallationFailure(msg) => ComponentInstallationError(msg) diff --git a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/ProjectServiceFailure.scala b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/ProjectServiceFailure.scala index 04ca202554..5262991411 100644 --- a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/ProjectServiceFailure.scala +++ b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/ProjectServiceFailure.scala @@ -84,6 +84,7 @@ object ProjectServiceFailure { * than what is currently running. */ case class ProjectManagerUpgradeRequiredFailure( + currentVersion: SemVer, minimumRequiredVersion: SemVer ) extends ProjectServiceFailure diff --git a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/versionmanagement/RuntimeVersionManagerErrorRecoverySyntax.scala b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/versionmanagement/RuntimeVersionManagerErrorRecoverySyntax.scala index 25fcad56d3..6cb85990af 100644 --- a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/versionmanagement/RuntimeVersionManagerErrorRecoverySyntax.scala +++ b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/service/versionmanagement/RuntimeVersionManagerErrorRecoverySyntax.scala @@ -29,6 +29,7 @@ object RuntimeVersionManagerErrorRecoverySyntax { MissingComponentFailure(message) case upgradeRequired: UpgradeRequiredError => ProjectManagerUpgradeRequiredFailure( + upgradeRequired.currentVersion, upgradeRequired.expectedVersion ) case UninstallationError(message) => diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala index 7a2bf0a126..8fcd9bbfe2 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala @@ -25,7 +25,7 @@ object CurrentVersion { /** Check if the current version is the development one. */ def isDevVersion: Boolean = - currentVersion == defaultDevEnsoVersion + currentVersion.preRelease == defaultDevEnsoVersion.preRelease /** Override launcher version with the provided one. * diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/ComponentsException.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/ComponentsException.scala index 6efa17534d..0d1653829d 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/ComponentsException.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/ComponentsException.scala @@ -59,13 +59,15 @@ case class ComponentMissingError(message: String, cause: Throwable = null) /** Indicates that a requested engine version requires a newer launcher/project * manager version. * + * @param currentVersion the current engine version * @param expectedVersion the minimum version that is required to run the engine */ case class UpgradeRequiredError( + currentVersion: SemVer, expectedVersion: SemVer ) extends ComponentsException( s"Minimum version required to use this engine is " + - s"$expectedVersion." + s"$expectedVersion. Current version is $currentVersion." ) /** Indicates uninstallation failure. */ diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala index 4a530be49f..8c2c4650c3 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala @@ -464,7 +464,10 @@ class RuntimeVersionManager( engineRelease.manifest ) if (!isCompatible) { - throw UpgradeRequiredError(engineRelease.manifest.minimumRequiredVersion) + throw UpgradeRequiredError( + CurrentVersion.version, + engineRelease.manifest.minimumRequiredVersion + ) } if (engineRelease.isBroken) { val continue = userInterface.shouldInstallBrokenEngine(version) @@ -726,7 +729,12 @@ class RuntimeVersionManager( ): Try[Manifest] = { Manifest.load(path / Manifest.DEFAULT_MANIFEST_NAME).flatMap { manifest => if (!isEngineVersionCompatibleWithThisInstaller(manifest)) { - Failure(UpgradeRequiredError(manifest.minimumRequiredVersion)) + Failure( + UpgradeRequiredError( + CurrentVersion.version, + manifest.minimumRequiredVersion + ) + ) } else Success(manifest) } }