Skip to content

Commit

Permalink
Fixing prepare-/publishDocs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pme123 committed Dec 14, 2024
1 parent dcff2bd commit 9740b77
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 41 deletions.
2 changes: 1 addition & 1 deletion 00-docs/src/docs/functionalityDsls/apiDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ GitConfigs(
)
)
```
This will clone or update these projects (`$cloneUrl/$project.git`) into `../git-temp`,
This will clone or update these projects (`$cloneUrl/$project.git`) into `../../git-temp`,
for example `https://github.com/mycompany/myProject.git`.

#### Used Dependency Resolution
Expand Down
5 changes: 3 additions & 2 deletions 03-api/src/main/scala/camundala/api/ApiConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ case class ApiConfig(
end ApiConfig

case class ProjectsConfig(
// Path, where the Git Projects are cloned.
gitDir: os.Path = os.pwd / os.up / "git-temp",
// Path, where the Git Projects are cloned - for dependency check.
// this for the structure: dev-myCompany/projects/myProject
gitDir: os.Path = os.pwd / os.up / os.up / "git-temp",
// Path to your ApiProjectConf
projectConfPath: os.RelPath = defaultProjectPath,
groupedConfigs: Seq[GroupedProjectConfig] = Seq.empty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package camundala.helper.dev

import camundala.api.ApiConfig
import camundala.helper.dev.company.docs.DocCreator
import camundala.helper.dev.publish.PublishHelper
import camundala.helper.dev.publish.PublishHelper.*
import camundala.helper.util.{DevConfig, Helpers, PublishConfig}

import scala.util.{Failure, Success, Try}

// dev-company/company-camundala/helper.scala
trait DevCompanyCamundalaHelper extends Helpers:
def apiConfig: ApiConfig
trait DevCompanyCamundalaHelper extends Helpers, DocCreator:
def devConfig: DevConfig
def publishConfig: Option[PublishConfig]

def runForCompany(command: String, arguments: String*): Unit =
val args = arguments.toSeq
Expand All @@ -32,12 +31,12 @@ trait DevCompanyCamundalaHelper extends Helpers:
case Command.publish =>
println("Usage: publish <version>")
case Command.prepareDocs =>
// DocCreator.prepareDocs()
case Command.releaseDocs =>
// CompanyDocCreator.releaseDocs()
prepareDocs()
case Command.publishDocs =>
publishDocs()

private enum Command:
case publish, prepareDocs, releaseDocs
case publish, prepareDocs, publishDocs

private def publish(newVersion: String): Unit =
println(s"Publishing ${devConfig.projectName}: $newVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import camundala.api.{ApiConfig, ApiProjectConf}

trait DependencyCreator:

protected given apiConfig: ApiConfig
protected given configs: Seq[ApiProjectConf]
protected given releaseConfig: ReleaseConfig = readReleaseConfig

protected def apiConfig: ApiConfig
protected def configs: Seq[ApiProjectConf]
protected def releaseConfig: ReleaseConfig = readReleaseConfig
given ApiConfig = apiConfig

case class Package(name: String, minorVersion: String):
lazy val show = s"$name:$minorVersion"
lazy val showRect = s"$name:$minorVersion($name:$minorVersion)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ case class DependencyLinkCreator()(using
|${packages
.filter(p => apiConfig.projectsConfig.hasProjectGroup(p.name, projectGroup))
.map { co =>
s"""- **${co.name}** [API Doc](../${co.name}/OpenApi.html "${co.name} API Documentation") - [Dependencies](./dependencies/${co.name}.html "${co.name} Dependencies")"""
s"""- **${co.name}:** [API Doc](../${co.name}/OpenApi.html "${co.name} API Documentation") - [Dependencies](./${releaseConfig.releaseTag}/dependencies/${co.name}.html "${co.name} Dependencies")"""
}
.mkString("\n")}
|""".stripMargin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package camundala.helper.dev.company.docs

import camundala.api.{ApiProjectConf, ProjectConfig, catalogFileName}
import camundala.helper.util.Helpers
import camundala.helper.dev.publish.DocsWebDAV
import camundala.helper.util.{Helpers, PublishConfig}
import os.Path

import java.time.LocalDate
Expand All @@ -13,13 +14,12 @@ import java.time.format.DateTimeFormatter
*/
trait DocCreator extends DependencyCreator, Helpers:

protected def publishConfig: Option[PublishConfig]
protected def gitBasePath: os.Path = apiConfig.projectsConfig.gitDir
protected given configs: Seq[ApiProjectConf] = setupConfigs()
protected def configs: Seq[ApiProjectConf] = setupConfigs()
lazy val projectConfigs: Seq[ProjectConfig] =
apiConfig.projectsConfig.projectConfigs

protected def upload(releaseTag: String): Unit

def prepareDocs(): Unit =
println(s"API Config: $apiConfig")
apiConfig.projectsConfig.init
Expand All @@ -30,7 +30,8 @@ trait DocCreator extends DependencyCreator, Helpers:
createReleasePage()
end prepareDocs

def releaseDocs(): Unit =
//noinspection ScalaUnusedExpression
def publishDocs(): Unit =
createDynamicConf()
println(s"Releasing Docs started")
os.proc(
Expand All @@ -39,8 +40,11 @@ trait DocCreator extends DependencyCreator, Helpers:
"clean",
"laikaSite" // generate HTML pages from Markup
).callOnConsole()
upload(releaseConfig.releaseTag)
end releaseDocs
publishConfig
.map: config =>
DocsWebDAV(apiConfig, config).upload(releaseConfig.releaseTag)
.getOrElse(println("No Publish Config found"))
end publishDocs

protected def createCatalog(): Unit =

Expand Down
36 changes: 19 additions & 17 deletions 04-helper/src/main/scala/camundala/helper/dev/publish/WebDAV.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.github.sardine.SardineFactory
import com.github.sardine.impl.SardineException

import java.nio.charset.StandardCharsets
import java.nio.file.Files
import scala.jdk.CollectionConverters.CollectionHasAsScala

abstract class WebDAV:
Expand Down Expand Up @@ -118,31 +119,18 @@ case class DocsWebDAV(apiConfig: ApiConfig, publishConfig: PublishConfig) extend
with Helpers:
def upload(releaseTag: String): Unit =
val sardine = startSession
val directories = Seq("helium", "releases")
val docDir = apiConfig.basePath / "target" / "docs" / "site"
if docDir.toIO.exists() then
// symbolic links for dependencies
os.proc(
"ln",
"-s",
s"./$releaseTag/dependencies",
docDir / "dependencies"
).callOnConsole()
// create also top level links for versioned root pages
Seq("helium", "index.html", "release.html", "overviewDependencies.html")
.foreach: f =>
println(s"Create symbolic link $f")
os.proc("ln", "-s", s"./$releaseTag/$f", docDir / f)
.callOnConsole()

try
println(s"Delete $publishBaseUrl/$releaseTag/")
if sardine.exists(s"$publishBaseUrl/$releaseTag/") then
sardine.delete(s"$publishBaseUrl/$releaseTag/")

def uploadFiles(url: String, docFiles: Seq[os.Path]): Unit =
docFiles.foreach {
case f if f.toIO.isDirectory && f.toIO.exists() =>
println(s"Create Directory $url/${f.toIO.getName}")
// if (!sardine.exists(s"$url/${f.toIO.getName}/"))
// sardine.createDirectory(s"$url/${f.toIO.getName}/")
//sardine.createDirectory(s"$url/${f.toIO.getName}")
uploadFiles(s"$url/${f.toIO.getName}", os.list(f))
case f if f.toIO.exists() =>
println(s"Uploading $url/${f.toIO.getName}")
Expand All @@ -151,6 +139,18 @@ case class DocsWebDAV(apiConfig: ApiConfig, publishConfig: PublishConfig) extend
println(s"Not supported file: $f")
}

def addSymbolicLinks =
// create top level links for versioned root pages / directories
Seq("index.html", "release.html", "overviewDependencies.html")
.foreach: f =>
println(s"Create symbolic link $f")
val symLink = docDir / f
Files.createSymbolicLink(symLink.toNIO, (docDir / releaseTag / f).toNIO)
// os.proc("ln", "-s", s"./$releaseTag/$f", docDir / f)
// .callOnConsole()
// sardine.put(s"$publishBaseUrl/${f.replace("dependencies", "dependencies/")}", os.read.inputStream(symLink))

addSymbolicLinks
uploadFiles(publishBaseUrl, os.list(docDir))
println(s"Finished upload Documentation")

Expand All @@ -167,4 +167,6 @@ case class DocsWebDAV(apiConfig: ApiConfig, publishConfig: PublishConfig) extend
)
end if
end upload


end DocsWebDAV
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait Helpers:
extension (proc: os.proc)

def callOnConsole(path: os.Path = os.pwd): Unit =
println(proc.command.mkString(" "))
println(proc.command.flatMap(_._1).mkString(" "))
val result = proc.call(cwd = path, stdout = os.Inherit)
println(result.out.text())
end extension
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ We use [mdoc](https://scalameta.org/mdoc/) to verify the documentation
and [laika](https://typelevel.org/Laika/) to generate the htmls.

Run mdoc: `sbt "docs/mdoc --watch"`
And laika: `sbt docs/laikaPreview`
And laika: `sbt "~docs/laikaPreview"`
Check the result in http://localhost:4242

0 comments on commit 9740b77

Please sign in to comment.