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

Update scalafmt-core to 2.7.0 #498

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
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