From cb8a70726d70de2d23eb0fb312ee92aab80aad17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Fri, 18 Jun 2021 14:15:41 +0200 Subject: [PATCH] Move edition providers to global config --- docs/distribution/distribution.md | 2 -- docs/libraries/editions.md | 4 +-- .../config/GlobalConfig.scala | 35 ++++++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/docs/distribution/distribution.md b/docs/distribution/distribution.md index 0b77d252068d..7e3e8c5185b1 100644 --- a/docs/distribution/distribution.md +++ b/docs/distribution/distribution.md @@ -75,7 +75,6 @@ extraction-location │ ├── Number.enso │ └── Text.enso ├── editions # Contains Edition specifications. -│ ├── sources.txt # Contains a list of Edition sources. │ ├── 2021.4.yaml │ └── nightly-2021-06-31.yaml ├── README.md # Information on layout and usage of the Enso distribution. @@ -106,7 +105,6 @@ ENSO_DATA_DIRECTORY │ ├── Number.enso │ └── Text.enso └── editions # Contains Edition specifications. - ├── sources.txt # Contains a list of Edition sources. ├── 2021.4.yaml └── nightly-2021-06-31.yaml diff --git a/docs/libraries/editions.md b/docs/libraries/editions.md index 0e22a60a169a..3ddda1281662 100644 --- a/docs/libraries/editions.md +++ b/docs/libraries/editions.md @@ -171,9 +171,7 @@ the directories. ### Updating the Editions -The file `$ENSO_DATA_DIRECTORY/editions/sources.txt` should contain a list of -edition provides. Each new line should consist of a single URL which should -return a list of editions that it provides. +The global user configuration file should contain a list of URLs specifying edition providers that should be used. By default (if the field is missing), it will default to our official edition provider, but users may add other providers or remove the official one. When `enso update-editions` is called or when requested by the IDE, these providers are queried and any new edition files are downloaded to the diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/config/GlobalConfig.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/config/GlobalConfig.scala index fd377c724874..36afd2f27d7f 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/config/GlobalConfig.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/config/GlobalConfig.scala @@ -15,12 +15,15 @@ import org.enso.pkg.Contact * projects * @param authorEmail default author (and maintainer) email for newly created * projects + * @param editionProviders a sequence of edition provider URLs that are used + * for downloading editions * @param original original mapping that may contain unknown keys */ case class GlobalConfig( defaultVersion: DefaultVersion, authorName: Option[String], authorEmail: Option[String], + editionProviders: Seq[String], original: JsonObject ) { @@ -35,23 +38,27 @@ case class GlobalConfig( } object GlobalConfig { + // TODO [RW] this should include the default provider once it is set up + private val defaultEditionProviders: Seq[String] = Seq() /** The default configuration used when the configuration file does not exist. */ val Default: GlobalConfig = GlobalConfig( - defaultVersion = DefaultVersion.LatestInstalled, - authorName = None, - authorEmail = None, - original = JsonObject() + defaultVersion = DefaultVersion.LatestInstalled, + authorName = None, + authorEmail = None, + editionProviders = defaultEditionProviders, + original = JsonObject() ) /** Field names used when serializing the configuration. */ object Fields { - val DefaultVersion = "default.enso-version" - val AuthorName = "author.name" - val AuthorEmail = "author.email" + val DefaultVersion = "default.enso-version" + val AuthorName = "author.name" + val AuthorEmail = "author.email" + val EditionProviders = "edition-providers" } /** [[Decoder]] instance for [[GlobalConfig]]. @@ -63,12 +70,16 @@ object GlobalConfig { ) authorName <- json.getOrElse[Option[String]](Fields.AuthorName)(None) authorEmail <- json.getOrElse[Option[String]](Fields.AuthorEmail)(None) - original <- json.as[JsonObject] + editionProviders <- json.getOrElse[Seq[String]](Fields.EditionProviders)( + defaultEditionProviders + ) + original <- json.as[JsonObject] } yield GlobalConfig( - defaultVersion = defaultVersion, - authorName = authorName, - authorEmail = authorEmail, - original = original + defaultVersion = defaultVersion, + authorName = authorName, + authorEmail = authorEmail, + editionProviders = editionProviders, + original = original ) }