Skip to content

Commit

Permalink
Removes Sbt-org-policies Dependency (#465)
Browse files Browse the repository at this point in the history
* Removes sbt-org-policies and
the dependency with itself

* Removes useless code

* Removes more useless code

* Updates docs

* Fix ci-docs command alias

* Apply suggestions from code review

Co-Authored-By: Ben Fradet <benjamin.fradet@gmail.com>

* Replaces handleError by handleErrorWith

Co-authored-by: Ben Fradet <benjamin.fradet@gmail.com>
  • Loading branch information
juanpedromoreno and BenFradet authored Apr 9, 2020
1 parent deb28ce commit d7d622b
Show file tree
Hide file tree
Showing 15 changed files with 715 additions and 137 deletions.
76 changes: 74 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray)
inThisBuild(
List(
name := "sbt-microsites",
organization := "com.47deg",
organizationName := "47 Degrees",
organizationHomepage := Some(url("https://www.47deg.com")),
homepage := Option(url("https://47degrees.github.io/sbt-microsites/")),
description := "An sbt plugin to create awesome microsites for your project",
startYear := Some(2016),
scalaVersion := V.scala
)
)

lazy val `sbt-microsites` = (project in file("."))
.settings(moduleName := "sbt-microsites")
Expand All @@ -21,4 +32,65 @@ lazy val docs = (project in file("docs"))
.enablePlugins(BuildInfoPlugin)

addCommandAlias("ci-test", "scalafmtCheck; scalafmtSbtCheck; docs/tut; compile; test; scripted")
addCommandAlias("ci-docs", "docs/tut")
addCommandAlias("ci-docs", "docs/tut; headerCreateAll")

lazy val V = new {
val ghPages: String = "0.6.3"
val github4s: String = "0.23.0"
val mdoc: String = "2.1.1"
val moultingyaml: String = "0.4.2"
val sbtSite: String = "1.4.0"
val scala: String = "2.12.11"
val scalatestScalacheck: String = "3.1.1.1"
val scalatags: String = "0.8.6"
val scrimage: String = "2.1.8"
val tut: String = "0.6.13"
}

lazy val noPublishSettings = Seq(
publish := ((): Unit),
publishLocal := ((): Unit),
publishArtifact := false,
publishMavenStyle := false // suppress warnings about intransitive deps (not published anyway)
)

lazy val pluginSettings: Seq[Def.Setting[_]] = Seq(
sbtPlugin := true,
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
"jgit-repo" at "https://download.eclipse.org/jgit/maven"
),
addSbtPlugin("org.tpolecat" % "tut-plugin" % V.tut),
addSbtPlugin("org.scalameta" % "sbt-mdoc" % V.mdoc),
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % V.ghPages),
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % V.sbtSite),
libraryDependencies ++= Seq(
"com.47deg" %% "github4s" % V.github4s,
"net.jcazevedo" %% "moultingyaml" % V.moultingyaml,
"com.lihaoyi" %% "scalatags" % V.scalatags,
"com.sksamuel.scrimage" %% "scrimage-core" % V.scrimage,
"org.scalatestplus" %% "scalacheck-1-14" % V.scalatestScalacheck % Test
),
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq(
"-Xmx2048M",
"-XX:ReservedCodeCacheSize=256m",
"-XX:+UseConcMarkSweepGC",
"-Dplugin.version=" + version.value,
"-Dscala.version=" + scalaVersion.value
)
}
)

lazy val micrositeSettings: Seq[Def.Setting[_]] = Seq(
micrositeName := "sbt-microsites",
micrositeDescription := "An sbt plugin to create awesome microsites for your project",
micrositeBaseUrl := "sbt-microsites",
micrositeDocumentationUrl := "docs",
micrositeGithubOwner := "47degrees",
micrositeGithubRepo := "sbt-microsites",
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
micrositePushSiteWith := GitHub4s,
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.md" | "*.svg"
)
1 change: 0 additions & 1 deletion docs/docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ Additionally, it depends on other useful libraries and plugins like:
* [sbt-pgp](https://github.com/sbt/sbt-pgp)
* [sbt-header](https://github.com/sbt/sbt-header)
* [GitHub4s](https://github.com/47deg/github4s)
* [sbt-org-policies](https://github.com/47deg/sbt-org-policies)
110 changes: 0 additions & 110 deletions project/ProjectPlugin.scala

This file was deleted.

31 changes: 22 additions & 9 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ import sbt.Resolver.sonatypeRepo

resolvers ++= Seq(sonatypeRepo("snapshots"), sonatypeRepo("releases"))

addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.13.3")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.1.5")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.4.0")
addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.6.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.6.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.6.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.2")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")

unmanagedSourceDirectories in Compile ++= Seq(
baseDirectory.in(ThisBuild).value.getParentFile / "src" / "main" / "scala"
)
libraryDependencies ++= Seq(
"com.47deg" %% "github4s" % "0.23.0",
"net.jcazevedo" %% "moultingyaml" % "0.4.2",
"com.lihaoyi" %% "scalatags" % "0.8.6",
"com.sksamuel.scrimage" %% "scrimage-core" % "2.1.8"
)
23 changes: 23 additions & 0 deletions src/main/scala/microsites/Exceptions.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package microsites

object Exceptions {

sealed abstract class MicrositesException(val message: String, val maybeCause: Option[Throwable])
extends RuntimeException(message)
with Product
with Serializable {

maybeCause foreach initCause

override def toString: String = message
}

case class IOException(msg: String, cause: Option[Throwable] = None)
extends MicrositesException(msg, cause)

case class GitHub4sException(msg: String, cause: Option[Throwable] = None)
extends MicrositesException(msg, cause)

final case class UnexpectedException(msg: String, cause: Option[Throwable] = None)
extends MicrositesException(msg, cause)
}
24 changes: 14 additions & 10 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import sbt.Keys._
import sbt._
import sbt.io.{IO => FIO}
import sbt.complete.DefaultParsers.OptNotSpace
import sbtorgpolicies.github.GitHubOps
import github.GitHubOps
import tut.TutPlugin.autoImport._
import mdoc.MdocPlugin.autoImport._
import sbtorgpolicies.io.FileReader
import sbtorgpolicies.io.FileWriter._
import sbtorgpolicies.io.syntax._
import microsites.ioops._
import microsites.ioops.syntax._
import FileWriter._
import cats.effect.{ContextShift, IO, Timer}
import scala.concurrent.ExecutionContext

Expand Down Expand Up @@ -518,12 +518,16 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {

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

ghOps.commitDir(branch, commitMessage, siteDir).value.unsafeRunSync() match {
case Right(_) => log.info("Success committing files")
case Left(e) =>
log.error(s"Error committing files")
e.printStackTrace()
}
ghOps
.commitDir(branch, commitMessage, siteDir)
.map(_ => log.info("Success committing files"))
.handleErrorWith { e =>
IO {
e.printStackTrace()
log.error(s"Error committing files")
}
}
.unsafeRunSync()
})
case (GitHub4s.name, GitHub.name) =>
Def.task(
Expand Down
16 changes: 16 additions & 0 deletions src/main/scala/microsites/github/Config.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package microsites.github

object Config {

val blobMode: String = "100644"
val blobType: String = "blob"

val defaultTextExtensions: Set[String] =
Set(".md", ".css", ".html", ".properties", ".txt", ".scala", ".sbt")
val defaultMaximumSize: Int = 4048

final case class BlobConfig(acceptedExtensions: Set[String], maximumSize: Int)

val defaultBlobConfig: BlobConfig = BlobConfig(defaultTextExtensions, defaultMaximumSize)

}
Loading

0 comments on commit d7d622b

Please sign in to comment.