Skip to content

Commit

Permalink
Move edition providers to global config
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jun 18, 2021
1 parent d22a54d commit cb8a707
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 0 additions & 2 deletions docs/distribution/distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions docs/libraries/editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand All @@ -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]].
Expand All @@ -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
)
}

Expand Down

0 comments on commit cb8a707

Please sign in to comment.