enso/project/Editions.scala
James Dunkerley 2f0d99a1cb
Snowflake Connectivity (#9435)
* Initial connection to Snowflake via an account, username and password.

* Fix databases and schemas in Snowflake.
Add warehouses.

* Add warehouse.
Update schema dropdowns.

* Add ability to set warehouse and pass at connect.

* Fix for NPE in license review

* scalafmt

* Separate Snowflake from Database.

* Scala fmt.

* Legal Review

* Avoid using ARROW for snowflake.

* Tidy up Entity_Naming_Properties.

* Fix for separating Entity_Namimg_Properties.

* Allow some tweaking of Postgres dialect to allow snowflake to use as well.

* Working on reading Date, Time and Date Times.

* Changelog.

* Java format.

* Make Snowflake Time and TimeStamp stuff work.
Move some responsibilities to Type_Mapping.

* Make Snowflake Time and TimeStamp stuff work.
Move some responsibilities to Type_Mapping.

* fix

* Update distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Connection.enso

Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>

* PR comments.

* Last refactor for PR.

* Fix.

---------

Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2024-03-20 10:06:12 +00:00

93 lines
2.7 KiB
Scala

import sbt._
object Editions {
/** List of libraries that are shipped with the engine and reside in the
* engine repository.
*
* They currently all share the version number.
*/
val standardLibraries: Seq[String] = Seq(
"Standard.Base",
"Standard.Test",
"Standard.Table",
"Standard.Database",
"Standard.AWS",
"Standard.Image",
"Standard.Geo",
"Standard.Visualization",
"Standard.Examples",
"Standard.Searcher",
"Standard.Google_Api",
"Standard.Snowflake"
)
case class ContribLibrary(name: String, version: String)
/** A list of additional libraries from external sources that are published in
* the main repository and should be available in the default edition.
*/
val contribLibraries: Seq[ContribLibrary] = Seq()
/** The URL to the main library repository. */
val mainLibraryRepositoryUrl = "https://libraries.release.enso.org/libraries"
private val extension = ".yaml"
/** Generates a base edition file for the engine release that contains the
* Standard library and is associated with the current Enso version.
*/
def writeEditionConfig(
editionsRoot: File,
ensoVersion: String,
editionName: String,
libraryVersion: String,
log: Logger
): Unit = {
IO.createDirectory(editionsRoot)
val edition = editionsRoot / (editionName + extension)
for (file <- IO.listFiles(editionsRoot)) {
if (file.getName != edition.getName) {
IO.delete(file)
log.warn(s"Removed spurious file in editions directory: $file")
}
}
val editionConfigContent = {
val standardLibrariesConfigs = standardLibraries.map { libName =>
s""" - name: $libName
| repository: main
| version: $libraryVersion""".stripMargin
}
val contribLibrariesConfigs = contribLibraries.map {
case ContribLibrary(name, version) =>
s""" - name: $name
| repository: main
| version: $version""".stripMargin
}
val librariesConfigs = standardLibrariesConfigs ++ contribLibrariesConfigs
val editionConfig =
s"""engine-version: $ensoVersion
|repositories:
| - name: main
| url: $mainLibraryRepositoryUrl
|libraries:
|${librariesConfigs.mkString("\n")}
|""".stripMargin
editionConfig
}
val currentContent = if (edition.exists()) Some(IO.read(edition)) else None
if (currentContent.contains(editionConfigContent)) {
log.debug(s"Edition config [$edition] is already up-to-date.")
} else {
IO.write(edition, editionConfigContent)
log.info(s"Written edition config to [$edition].")
}
}
}