-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for sbt 2 pre-release and final
- Loading branch information
Showing
14 changed files
with
151 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
modules/infra/src/main/scala/scaladex/infra/migrations/V25__fix_sbt_platform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package scaladex.infra.migrations | ||
import com.typesafe.scalalogging.LazyLogging | ||
import doobie.Query0 | ||
import doobie.util.update.Update | ||
import org.flywaydb.core.api.migration.BaseJavaMigration | ||
import org.flywaydb.core.api.migration.Context | ||
import scaladex.core.model._ | ||
import scaladex.infra.sql.DoobieUtils.Mappings._ | ||
import scaladex.infra.sql.DoobieUtils.selectRequest | ||
import scaladex.infra.sql.DoobieUtils.updateRequest | ||
|
||
class V25__fix_sbt_platform extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { | ||
override def migrate(context: Context): Unit = | ||
try { | ||
val request = | ||
for { | ||
artifactRefs <- selectArtifactRefs.to[Seq] | ||
_ <- updatePlatformAndLanguage.updateMany(artifactRefs.map(a => (a.platform, a.language, a))) | ||
} yield () | ||
run(xa)(request).unsafeRunSync() | ||
|
||
} catch { | ||
case e: Throwable => | ||
logger.info("failed to migrate the database") | ||
throw new Exception(s"failed to migrate the database because of ${e.getMessage}") | ||
} | ||
|
||
val selectArtifactRefs: Query0[Artifact.Reference] = selectRequest( | ||
"artifacts", | ||
Seq("group_id", "artifact_id", "version"), | ||
where = Seq("platform='sbt1.0' OR artifact_id LIKE '%_sbt2.0.0-M2_3'") | ||
) | ||
|
||
val updatePlatformAndLanguage: Update[(Platform, Language, Artifact.Reference)] = | ||
updateRequest("artifacts", Seq("platform", "language_version"), Seq("group_id", "artifact_id", "version")) | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
modules/infra/src/main/scala/scaladex/infra/migrations/V26__fix_artifact_names.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package scaladex.infra.migrations | ||
import com.typesafe.scalalogging.LazyLogging | ||
import doobie.Query0 | ||
import doobie.util.update.Update | ||
import org.flywaydb.core.api.migration.BaseJavaMigration | ||
import org.flywaydb.core.api.migration.Context | ||
import scaladex.core.model._ | ||
import scaladex.infra.sql.DoobieUtils.Mappings._ | ||
import scaladex.infra.sql.DoobieUtils.selectRequest | ||
import scaladex.infra.sql.DoobieUtils.updateRequest | ||
|
||
class V26__fix_artifact_names extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { | ||
override def migrate(context: Context): Unit = | ||
try { | ||
val request = | ||
for { | ||
artifactRefs <- selectArtifactRefs.to[Seq] | ||
_ <- updateNames.updateMany(artifactRefs.map(a => (a.name, a))) | ||
} yield () | ||
run(xa)(request).unsafeRunSync() | ||
|
||
} catch { | ||
case e: Throwable => | ||
logger.info("failed to migrate the database") | ||
throw new Exception(s"failed to migrate the database because of ${e.getMessage}") | ||
} | ||
|
||
val selectArtifactRefs: Query0[Artifact.Reference] = selectRequest( | ||
"artifacts", | ||
Seq("group_id", "artifact_id", "version"), | ||
where = Seq("artifact_id LIKE '%_sbt2.0.0-M2_3'") | ||
) | ||
|
||
val updateNames: Update[(Artifact.Name, Artifact.Reference)] = | ||
updateRequest("artifacts", Seq("artifact_name"), Seq("group_id", "artifact_id", "version")) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
modules/template/src/test/scala/scaladex/view/model/EcosystemHightlightTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package scaladex.view.model | ||
|
||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import scaladex.core.model._ | ||
|
||
class EcosystemHighlightTest extends AnyFunSpec with Matchers { | ||
it("ordering") { | ||
val `1.x` = EcosystemVersion(Version(1), 0, Url("")) | ||
val `0.13` = EcosystemVersion(Version(0, 13), 0, Url("")) | ||
val `2.0.0-M2` = | ||
EcosystemVersion(Version.SemanticLike(2, Some(0), Some(0), preRelease = Some(Milestone(2))), 0, Url("")) | ||
|
||
val highlight = EcosystemHighlight("sbt", Seq(`1.x`, `0.13`, `2.0.0-M2`)).get | ||
highlight.currentVersion shouldBe `1.x` | ||
(highlight.otherVersions should contain).theSameElementsInOrderAs(Seq(`0.13`, `2.0.0-M2`)) | ||
} | ||
} |