Skip to content

Commit

Permalink
Adjusted Documentation for changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pme123 committed Jan 5, 2025
1 parent ea26b5c commit 9e68f34
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 111 deletions.
117 changes: 54 additions & 63 deletions 00-docs/src/docs/company/04-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
With the `CompanyDevHelper` you can customize the development process for each project.

```scala
case class CompanyDevHelper(projectName: String, subProjects: Seq[String] = Seq.empty)
case object CompanyDevHelper
extends DevHelper:

lazy val apiConfig: ApiConfig = CompanyApiCreator.apiConfig
lazy val devConfig: DevConfig = CompanyDevConfig.config(projectName, subProjects)
lazy val apiConfig: ApiConfig = CompanyApiCreator.apiConfig
lazy val devConfig: DevConfig = CompanyDevConfig.config

end CompanyDevHelper
```
Expand All @@ -23,65 +23,56 @@ The `CompanyDevConfig` is a helper to create the `DevConfig` for the `CompanyDev

```scala
object CompanyDevConfig:
def config(
projectName: String,
subProjects: Seq[String] = Seq.empty
) = DevConfig(
projectName,
subProjects,
camundala.api.defaultProjectConfigPath
).withVersionConfig(companyVersionConfig)
// .withSbtConfig(SbtConfig(...))
// .withPublishConfig(PublishConfig(...))
// .withPostmanConfig(PostmanConfig(...))
// .withDockerConfig(DockerConfig(...))

private lazy val companyVersionConfig = VersionConfig(
scalaVersion = BuildInfo.scalaVersion,
camundalaVersion = BuildInfo.camundalaV,
companyCamundalaVersion = BuildInfo.version,
sbtVersion = BuildInfo.sbtVersion,
otherVersions = Map()
)

lazy val companyConfig =
config(
ApiProjectConfig(
projectName = BuildInfo.name,
projectVersion = BuildInfo.version
)
)

lazy val config: DevConfig =
config(ApiProjectConfig())

def config(apiProjectConfig: ApiProjectConfig) =
DevConfig(
apiProjectConfig,
//sbtConfig = companySbtConfig,
//versionConfig = companyVersionConfig,
//publishConfig = Some(companyPublishConfig),
//postmanConfig = Some(companyPostmanConfig),
//dockerConfig = companyDockerConfig
)

private lazy val companyVersionConfig = CompanyVersionConfig(
scalaVersion = BuildInfo.scalaVersion,
camundalaVersion = BuildInfo.camundalaV,
companyCamundalaVersion = BuildInfo.version,
sbtVersion = BuildInfo.sbtVersion,
otherVersions = Map()
)
end CompanyDevConfig
```
Here the default values for `DevConfig`:
```scala
case class DevConfig(
// project configuration taken from the PROJECT.conf
apiProjectConf: ApiProjectConf,
// subProjects to optimize compilation time - use only for big projects
subProjects: Seq[String] = Seq.empty,
// additional sbt configuration for sbt generation
sbtConfig: SbtConfig = SbtConfig(),
// versions used for generators
versionConfig: VersionConfig = VersionConfig(),
// If you have a Postman account, add the config here (used for ./helper.scala deploy..)
postmanConfig: Option[PostmanConfig] = None,
// Adjust the DockerConfig (used for ./helper.scala deploy../ docker..)
dockerConfig: DockerConfig = DockerConfig(),
// If you have a webdav server to publish the docs, add the config here (used in ./helper.scala publish..)
publishConfig: Option[PublishConfig] = None,
// general project structure - do not change if possible
modules: Seq[ModuleConfig] = DevConfig.modules
// project configuration taken from the PROJECT.conf
apiProjectConfig: ApiProjectConfig,
// additional sbt configuration for sbt generation
sbtConfig: SbtConfig = SbtConfig(),
// versions used for generators
versionConfig: CompanyVersionConfig = CompanyVersionConfig(),
// If you have a Postman account, add the config here (used for ./helper.scala deploy..)
postmanConfig: Option[PostmanConfig] = None,
// Adjust the DockerConfig (used for ./helper.scala deploy../ docker..)
dockerConfig: DockerConfig = DockerConfig(),
// If you have a webdav server to publish the docs, add the config here (used in ./helper.scala publish..)
publishConfig: Option[PublishConfig] = None,
// general project structure - do not change if possible -
modules: Seq[ModuleConfig] = DevConfig.modules
)
```
### defaultProjectConfigPath

At the moment we use a configuration file for each project. **This may change in the future.**
The default path is `projectBasePath / PROJECT.conf` and is generated by `./helper.scala update` in the project.

Example:
```scala
org = "mycompany"
name = "mycompany-accounting"
version = "1.25.0-SNAPSHOT"
dependencies: {
"mycompany-helper": "mycompany:mycompany-helper:1.4.*"
"mycompany-services": "mycompany:mycompany-services:1.7.*"
"mycompany-crm": "mycompany:mycompany-crm:2.28.*"
}
```

## CompanyCamundalaDevHelper
The `CompanyCamundalaDevHelper` is a helper dedicated for the `company-camundala` project.
Expand All @@ -90,16 +81,16 @@ See [Development]

```scala
object CompanyCamundalaDevHelper
extends DevCompanyCamundalaHelper:
extends DevCompanyCamundalaHelper:

lazy val apiConfig: ApiConfig = CompanyApiCreator.apiConfig
.copy(
basePath = os.pwd /"00-docs",
tempGitDir = os.pwd / os.up / "git-temp"
)
lazy val apiConfig: ApiConfig = CompanyApiCreator.apiConfig
.copy(
basePath = os.pwd / "00-docs",
tempGitDir = os.pwd / os.up / "git-temp"
)

lazy val devConfig: DevConfig = CompanyDevConfig.companyConfig

lazy val devConfig: DevConfig = CompanyDevConfig.config(BuildInfo.name, Seq.empty)

end CompanyCamundalaDevHelper
```

Expand Down
2 changes: 2 additions & 0 deletions 00-docs/src/docs/company/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ helium.site.pageNavigation.enabled = false
A Company Project handles the specific configuration for the company.

@:callout(info)
**Be aware** that this is not tested.

Make sure you have [init the company](../development/initCompany.md).

In this process many files are generated and some are replaced.
Expand Down
16 changes: 16 additions & 0 deletions 00-docs/src/docs/development/createProject.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Here we focus on the first step.
| projects
| | myProject
| | | helper.scala
| | | PROJECT.conf
```

1. Make `helper.scala` executable:
Expand All @@ -38,6 +39,21 @@ chmod +x helper.scala

1. Open the `mycompany-myProject` directory with your IDE (I use Intellij).

1. Adjust the `PROJECT.conf` to your needs.

```
projectName: mycompany-myProject
projectVersion: 0.1.0-SNAPSHOT
subProjects: [
// subProject1
// subProject2
]
dependencies: {
// mastercompany-services: 1.2.4
// mycompany-commons: 1.0.3
}
```

@:callout(info)
If you haven't released `company-camundala` yet,
you need to run it at least locally (`sbt publishLocal`)
Expand Down
11 changes: 6 additions & 5 deletions 03-api/src/main/scala/camundala/api/ApiCreator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ trait ApiCreator extends PostmanApiCreator, TapirApiCreator, App:

protected def companyProjectVersion: String
protected def projectDescr: String
protected def apiProjectConfig: ApiProjectConfig = ApiProjectConfig(apiConfig.projectConfPath)

def supportedVariables: Seq[InputParams] =
InputParams.values.toSeq
Expand All @@ -29,7 +30,7 @@ trait ApiCreator extends PostmanApiCreator, TapirApiCreator, App:
ModelerTemplGenerator(version, apiConfig.modelerTemplateConfig, Some(projectName)).generate(
collectApis(apiDoc)
)
ModelerTemplUpdater(apiConfig).update()
ModelerTemplUpdater(apiConfig, apiProjectConfig).update()
writeOpenApis(apiDoc)
writeCatalog(apiDoc)
end document
Expand Down Expand Up @@ -290,7 +291,7 @@ trait ApiCreator extends PostmanApiCreator, TapirApiCreator, App:
s"""|### Dependencies:
|
|${
apiProjectConf.dependencies
docProjectConfig.dependencies
.map(dep => s"- _**[${dep.projectName}](${documentations.getOrElse(dep.projectName, "NOT FOUND")})**_")
.mkString("\n")
}
Expand Down Expand Up @@ -324,8 +325,8 @@ trait ApiCreator extends PostmanApiCreator, TapirApiCreator, App:
|
|> Created with:
|> - [camundala-api v${BuildInfo.version}](https://github.com/pme123/camundala)
|> - ${apiProjectConf.companyName}-camundala-api $companyProjectVersion
|> - ${apiProjectConf.companyName}-camundala-helper
|> - ${docProjectConfig.companyName}-camundala-api $companyProjectVersion
|> - ${docProjectConfig.companyName}-camundala-helper
|
|""".stripMargin

Expand Down Expand Up @@ -398,6 +399,6 @@ trait ApiCreator extends PostmanApiCreator, TapirApiCreator, App:
|like `"$example"`""".stripMargin

private lazy val packageConfPath = apiConfig.basePath / apiConfig.projectsConfig.projectConfPath
private lazy val apiProjectConf = DocProjectConfig(packageConfPath)
private lazy val docProjectConfig = DocProjectConfig(apiProjectConfig)

end ApiCreator
30 changes: 5 additions & 25 deletions 03-api/src/main/scala/camundala/api/DocProjectConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,22 @@ object DocProjectConfig:
lazy val defaultVersion = "0.1.0"

def apply(
packageFile: os.Path
apiProjectConfig: ApiProjectConfig
): DocProjectConfig =
apply(packageFile, Seq.empty, DocProjectConfig.defaultVersion, false)
apply(apiProjectConfig, Seq.empty, DocProjectConfig.defaultVersion, false)

def apply(
packageFile: os.Path,
apiProjectConfig: ApiProjectConfig,
changelog: Seq[String],
versionPrevious: String,
isWorker: Boolean
): DocProjectConfig =
val apiProjectConfig = ApiProjectConfig(packageFile)
DocProjectConfig(
apiProjectConfig,
versionPrevious,
changelog,
isWorker
)
end apply

def init(projectName: String, newPackageFile: os.Path) =
if !os.exists(newPackageFile)
then
println(s"Created initial $newPackageFile")
os.makeDir.all(newPackageFile / os.up)
os.write(
newPackageFile,
s"""
|org = "${projectName.split("-").head}"
|name = "$projectName"
|version = "${DocProjectConfig.defaultVersion}"
|dependencies: {
|
|}
|""".stripMargin
)
end if
apply(newPackageFile)
end init


end DocProjectConfig
16 changes: 8 additions & 8 deletions 03-api/src/main/scala/camundala/api/ModelerTemplUpdater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import scala.language.postfixOps
import scala.xml.*
import scala.xml.transform.{RewriteRule, RuleTransformer}

case class ModelerTemplUpdater(apiConfig: ApiConfig):

case class ModelerTemplUpdater(apiConfig: ApiConfig, apiProjectConfig: ApiProjectConfig):
def update(): Unit =
updateTemplates()
updateBpmnColors()

private def updateTemplates(): Unit =
apiProjectConfig.dependencies
docProjectConfig.dependencies
.foreach: c =>
val toPath = templConfig.templatePath / "dependencies"
os.makeDir.all(toPath)
Expand All @@ -33,7 +33,7 @@ case class ModelerTemplUpdater(apiConfig: ApiConfig):
.map:
case t
if t.elementType.value == AppliesTo.`bpmn:CallActivity` &&
t.name != apiProjectConfig.projectName =>
t.name != docProjectConfig.projectName =>
val newTempl =
t.asJson
.deepDropNullValues
Expand All @@ -50,7 +50,7 @@ case class ModelerTemplUpdater(apiConfig: ApiConfig):

private def updateBpmnColors(): Unit =
println("Adjust Color for:")
projectsConfig.projectConfig(apiProjectConfig.projectName)
projectsConfig.projectConfig(docProjectConfig.projectName)
.map: pc =>
os.walk(os.pwd / diagramPath)
.filter:
Expand All @@ -60,10 +60,10 @@ case class ModelerTemplUpdater(apiConfig: ApiConfig):
.map:
extractUsesRefs
end updateBpmnColors

private lazy val templConfig = apiConfig.modelerTemplateConfig
private lazy val projectsConfig = apiConfig.projectsConfig
private lazy val apiProjectConfig = DocProjectConfig(apiConfig.projectConfPath)
private lazy val docProjectConfig: DocProjectConfig = DocProjectConfig(apiProjectConfig)
private lazy val colorMap = apiConfig.projectsConfig.colors.toMap

private def extractUsesRefs(bpmnPath: os.Path, xmlStr: String) =
Expand Down Expand Up @@ -97,7 +97,7 @@ case class ModelerTemplUpdater(apiConfig: ApiConfig):
val xmlNew = (callActivities ++ businessRuleTasks ++ externalWorkers)
.filter:
case project -> _ =>
colorMap.contains(project) && apiProjectConfig.projectName != project
colorMap.contains(project) && docProjectConfig.projectName != project
.foldLeft(xml):
case (xmlResult, project -> id) =>
println(s" -> $project > $id -- ${colorMap(project)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ case class CompanyDocsGenerator(companyCamundala: os.Path):
private def directory(name: String, title: String, isVersioned: Boolean) =
os.makeDir.all(docsSrc / name)
createIfNotExists(
docsSrc / name / "directory.md",
docsSrc / name / "directory.conf",
s"""|${laikaVersioned(isVersioned)}
|
|${laikaTitle(title)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,14 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
| lazy val config: DevConfig =
| config(ApiProjectConfig())
|
| def config(apiProjectConfig: ApiProjectConfig): DevConfig =
| DevConfig(apiProjectConfig)
| // .withVersionConfig(companyVersionConfig)
| // .withSbtConfig(SbtConfig(...))
| // .withPublishConfig(PublishConfig(...))
| // .withPostmanConfig(PostmanConfig(...))
| // .withDockerConfig(DockerConfig(...))
| def config(apiProjectConfig: ApiProjectConfig) = DevConfig(
| apiProjectConfig,
| //sbtConfig = companySbtConfig,
| //versionConfig = companyVersionConfig,
| //publishConfig = Some(companyPublishConfig),
| //postmanConfig = Some(companyPostmanConfig),
| //dockerConfig = companyDockerConfig
| )
|
| private lazy val companyVersionConfig = CompanyVersionConfig(
| scalaVersion = BuildInfo.scalaVersion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package camundala.helper.dev.company.docs

import camundala.api.{DocProjectConfig, ProjectConfig, catalogFileName}
import camundala.api.{ApiProjectConfig, DocProjectConfig, ProjectConfig, catalogFileName}
import camundala.helper.dev.publish.DocsWebDAV
import camundala.helper.util.{Helpers, PublishConfig}
import os.Path
Expand All @@ -17,6 +17,8 @@ trait DocCreator extends DependencyCreator, Helpers:
protected def publishConfig: Option[PublishConfig]
protected def gitBasePath: os.Path = apiConfig.tempGitDir
protected def configs: Seq[DocProjectConfig] = setupConfigs()
protected def apiProjectConfig(projectConfigPath: os.Path): ApiProjectConfig = ApiProjectConfig(projectConfigPath)

lazy val projectConfigs: Seq[ProjectConfig] =
apiConfig.projectsConfig.projectConfigs

Expand Down Expand Up @@ -193,7 +195,7 @@ trait DocCreator extends DependencyCreator, Helpers:
.proc("git", "checkout", s"tags/v$version")
.callOnConsole(projectPath)
yield DocProjectConfig(
projectPath / apiConfig.projectsConfig.projectConfPath,
apiProjectConfig(projectPath / apiConfig.projectsConfig.projectConfPath),
os.read.lines(projectPath / "CHANGELOG.md"),
versionPrevious,
isWorker
Expand Down

0 comments on commit 9e68f34

Please sign in to comment.