Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cats-effect IO data type #449

Merged
merged 5 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ object ProjectPlugin extends AutoPlugin {
object autoImport {

lazy val V = new {
val catsEffect: String = "1.1.0"
calvellido marked this conversation as resolved.
Show resolved Hide resolved
franciscodr marked this conversation as resolved.
Show resolved Hide resolved
val mdoc: String = "2.1.1"
val moultingyaml: String = "0.4.1"
val orgPolicies: String = "0.13.1"
val orgPolicies: String = "0.13.2"
val scala: String = "2.12.10"
val scalactic: String = "3.1.1"
val scalatest: String = "3.1.1"
Expand All @@ -40,6 +41,7 @@ object ProjectPlugin extends AutoPlugin {
addSbtPlugin(%("sbt-ghpages", isSbtPlugin = true)),
addSbtPlugin(%("sbt-site", isSbtPlugin = true)),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % V.catsEffect,
%%("org-policies-core", V.orgPolicies),
%%("moultingyaml", V.moultingyaml),
%%("scalatags", V.scalatags),
Expand Down
13 changes: 10 additions & 3 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ import io.circe.generic.semiauto._
import io.circe.syntax._
import sbt.Keys._
import sbt._
import sbt.io.{IO => FIO}
import sbt.complete.DefaultParsers.OptNotSpace
import sbtorgpolicies.github.GitHubOps
import tut.TutPlugin.autoImport._
import mdoc.MdocPlugin.autoImport._
import sbtorgpolicies.io.FileReader
import sbtorgpolicies.io.FileWriter._
import sbtorgpolicies.io.syntax._
import cats.effect.{ContextShift, IO, Timer}
import scala.concurrent.ExecutionContext

import scala.sys.process._
import java.nio.file._
Expand Down Expand Up @@ -494,6 +497,10 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
val githubRepo: String = micrositeGithubRepo.value
val githubToken: Option[String] = micrositeGithubToken.value

implicit val cs: ContextShift[IO] = IO.contextShift(ExecutionContext.global)
implicit val ec: ExecutionContext = ExecutionContext.global
implicit val t: Timer[IO] = IO.timer(ExecutionContext.global)

lazy val log: Logger = streams.value.log

(pushSiteWith.name, gitHosting.name) match {
Expand All @@ -506,11 +513,11 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
| * repo: $githubOwner/$githubRepo
| * commitMessage: $commitMessage""".stripMargin)

val ghOps: GitHubOps = new GitHubOps(githubOwner, githubRepo, githubToken)
val ghOps: GitHubOps[IO] = new GitHubOps[IO](githubOwner, githubRepo, githubToken)

if (noJekyll) IO.touch(siteDir / ".nojekyll")
if (noJekyll) FIO.touch(siteDir / ".nojekyll")

ghOps.commitDir(branch, commitMessage, siteDir) match {
ghOps.commitDir(branch, commitMessage, siteDir).value.unsafeRunSync() match {
case Right(_) => log.info("Success committing files")
case Left(e) =>
log.error(s"Error committing files")
Expand Down