Skip to content

Commit

Permalink
Update scalafmt-core to 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
47erbot authored Sep 9, 2020
1 parent cfa04e1 commit ce4151d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 2.5.3
version = 2.7.0
style = defaultWithAlign
maxColumn = 100

Expand Down
29 changes: 14 additions & 15 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -513,22 +513,21 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
| * commitMessage: $commitMessage""".stripMargin)

BlazeClientBuilder[IO](ec).resource
.use {
client =>
val ghOps: GitHubOps[IO] =
new GitHubOps[IO](client, githubOwner, githubRepo, githubToken)

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

ghOps
.commitDir(branch, commitMessage, siteDir)
.map(_ => log.info("Success committing files"))
.handleErrorWith { e =>
IO {
e.printStackTrace()
log.error(s"Error committing files")
}
.use { client =>
val ghOps: GitHubOps[IO] =
new GitHubOps[IO](client, githubOwner, githubRepo, githubToken)

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

ghOps
.commitDir(branch, commitMessage, siteDir)
.map(_ => log.info("Success committing files"))
.handleErrorWith { e =>
IO {
e.printStackTrace()
log.error(s"Error committing files")
}
}
}
.unsafeRunSync()
})
Expand Down
57 changes: 26 additions & 31 deletions src/main/scala/microsites/util/MicrositeHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,24 @@ class MicrositeHelper(config: MicrositeSettings) {
val extraMdOutputDir = config.fileLocations.micrositeExtraMdFilesOutput
extraMdOutputDir.mkdirs()

config.fileLocations.micrositeExtraMdFiles foreach {
case (sourceFile, targetFileConfig) =>
println(
s"Copying from ${sourceFile.getAbsolutePath} to ${extraMdOutputDir.getAbsolutePath}/$targetFileConfig"
)
config.fileLocations.micrositeExtraMdFiles foreach { case (sourceFile, targetFileConfig) =>
println(
s"Copying from ${sourceFile.getAbsolutePath} to ${extraMdOutputDir.getAbsolutePath}/$targetFileConfig"
)

val targetFileContent =
s"""---
val targetFileContent =
s"""---
|layout: ${targetFileConfig.layout}
|${targetFileConfig.metaProperties map {
case (key, value) => "%s: %s" format (key, value)
} mkString ("", "\n", "")}
|${targetFileConfig.metaProperties map { case (key, value) =>
"%s: %s" format (key, value)
} mkString ("", "\n", "")}
|---
|${Source.fromFile(sourceFile.getAbsolutePath).mkString}
|""".stripMargin

val outFile = extraMdOutputDir / targetFileConfig.fileName
val outFile = extraMdOutputDir / targetFileConfig.fileName

IO.write(outFile, targetFileContent)
IO.write(outFile, targetFileContent)
}

extraMdOutputDir
Expand Down Expand Up @@ -179,8 +178,8 @@ class MicrositeHelper(config: MicrositeSettings) {
createFile(targetPath)

val content = config.visualSettings.palette
.map {
case (key, value) => s"""$$$key: $value;"""
.map { case (key, value) =>
s"""$$$key: $value;"""
}
.mkString("\n")
writeContentToFile(content, targetPath)
Expand All @@ -204,22 +203,20 @@ class MicrositeHelper(config: MicrositeSettings) {
"page" -> new PageLayout(config)
)

layoutList map {
case (layoutName, layout) =>
val targetPath = s"$targetDir$jekyllDir/_layouts/$layoutName.html"
createFile(targetPath)
layoutList map { case (layoutName, layout) =>
val targetPath = s"$targetDir$jekyllDir/_layouts/$layoutName.html"
createFile(targetPath)

writeContentToFile("<!DOCTYPE html>" + layout.render.toString(), targetPath)
targetPath.toFile
writeContentToFile("<!DOCTYPE html>" + layout.render.toString(), targetPath)
targetPath.toFile
}
}

def createPartialLayout(targetDir: String): List[File] =
List("menu" -> new MenuPartialLayout(config)) map {
case (layoutName, layout) =>
val targetPath = s"$targetDir$jekyllDir/_includes/$layoutName.html"
writeContentToFile(layout.render.toString(), targetPath)
targetPath.toFile
List("menu" -> new MenuPartialLayout(config)) map { case (layoutName, layout) =>
val targetPath = s"$targetDir$jekyllDir/_includes/$layoutName.html"
writeContentToFile(layout.render.toString(), targetPath)
targetPath.toFile
}

def createFavicons(targetDir: String): List[File] = {
Expand All @@ -233,13 +230,11 @@ class MicrositeHelper(config: MicrositeSettings) {
createFile(sourceFile)

(faviconFilenames zip faviconSizes)
.map {
case (name, size) =>
(new File(s"$targetDir$jekyllDir/img/$name"), size)
.map { case (name, size) =>
(new File(s"$targetDir$jekyllDir/img/$name"), size)
}
.map {
case (file, (width, height)) =>
Image.fromFile(sourceFile.toFile).scaleTo(width, height).output(file)
.map { case (file, (width, height)) =>
Image.fromFile(sourceFile.toFile).scaleTo(width, height).output(file)
}
}

Expand Down

0 comments on commit ce4151d

Please sign in to comment.