Skip to content

Commit 0ef49da

Browse files
committed
Added Helper documentation.
1 parent 16ca223 commit 0ef49da

File tree

15 files changed

+271
-80
lines changed

15 files changed

+271
-80
lines changed

00-docs/src/docs/company/00-docs.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ The following files will be created by `.helper.scala prepareDocs`:
2525
| - overviewDependencies.md
2626
| - release.md
2727
```
28-
So do **not adjust** them manually.
28+
So do **not adjust** them manually.
29+

00-docs/src/docs/company/04-helper.md

Lines changed: 105 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,113 @@
11
# 04-helper
22

3-
### CompanyDevHelper
4-
With the `CompanyDevHelper` you can customize _Camundala_ for your Company:
5-
6-
```scala mdoc
7-
import camundala.api.*
8-
import camundala.helper.dev.DevHelper
9-
import camundala.helper.util.*
3+
## CompanyDevHelper
4+
With the `CompanyDevHelper` you can customize the development process for each project.
105

6+
```scala
117
case class CompanyDevHelper(projectName: String, subProjects: Seq[String] = Seq.empty)
12-
extends DevHelper:
8+
extends DevHelper:
9+
10+
lazy val apiConfig: ApiConfig = CompanyApiCreator.apiConfig
11+
lazy val devConfig: DevConfig = CompanyDevConfig.config(projectName, subProjects)
12+
13+
end CompanyDevHelper
14+
```
15+
### ApiConfig
16+
Taken from `CompanyApiCreator.apiConfig`, see [CompanyApiCreator]
17+
18+
### DevConfig
19+
Taken from `CompanyApiCreator.apiConfig`, see [CompanyDevConfig]
1320

14-
lazy val apiConfig: ApiConfig = ApiConfig("mycompany")//.withTenantId("mycompany")...
21+
## CompanyDevConfig
22+
The `CompanyDevConfig` is a helper to create the `DevConfig` for the `CompanyDevHelper`.
23+
24+
```scala
25+
object CompanyDevConfig:
26+
def config(
27+
projectName: String,
28+
subProjects: Seq[String] = Seq.empty
29+
) = DevConfig(
30+
projectName,
31+
subProjects,
32+
camundala.api.defaultProjectConfigPath
33+
).withVersionConfig(companyVersionConfig)
34+
// .withSbtConfig(SbtConfig(...))
35+
// .withPublishConfig(PublishConfig(...))
36+
// .withPostmanConfig(PostmanConfig(...))
37+
// .withDockerConfig(DockerConfig(...))
38+
39+
private lazy val companyVersionConfig = VersionConfig(
40+
scalaVersion = BuildInfo.scalaVersion,
41+
camundalaVersion = BuildInfo.camundalaV,
42+
companyCamundalaVersion = BuildInfo.version,
43+
sbtVersion = BuildInfo.sbtVersion,
44+
otherVersions = Map()
45+
)
46+
end CompanyDevConfig
47+
```
48+
Here the default values for `DevConfig`:
49+
```scala
50+
case class DevConfig(
51+
// project configuration taken from the PROJECT.conf
52+
apiProjectConf: ApiProjectConf,
53+
// subProjects to optimize compilation time - use only for big projects
54+
subProjects: Seq[String] = Seq.empty,
55+
// additional sbt configuration for sbt generation
56+
sbtConfig: SbtConfig = SbtConfig(),
57+
// versions used for generators
58+
versionConfig: VersionConfig = VersionConfig(),
59+
// If you have a Postman account, add the config here (used for ./helper.scala deploy..)
60+
postmanConfig: Option[PostmanConfig] = None,
61+
// Adjust the DockerConfig (used for ./helper.scala deploy../ docker..)
62+
dockerConfig: DockerConfig = DockerConfig(),
63+
// If you have a webdav server to publish the docs, add the config here (used in ./helper.scala publish..)
64+
publishConfig: Option[PublishConfig] = None,
65+
// general project structure - do not change if possible
66+
modules: Seq[ModuleConfig] = DevConfig.modules
67+
)
68+
```
69+
### defaultProjectConfigPath
1570

16-
lazy val deployConfig: Option[DeployConfig] = ???
17-
lazy val devConfig: DevConfig = ???
18-
lazy val dockerConfig: DockerConfig = ???
19-
lazy val publishConfig: Option[PublishConfig] = ???
71+
At the moment we use a configuration file for each project. **This may change in the future.**
72+
The default path is `projectBasePath / PROJECT.conf` and is generated by `./helper.scala update` in the project.
2073

74+
Example:
75+
```scala
76+
org = "mycompany"
77+
name = "mycompany-accounting"
78+
version = "1.25.0-SNAPSHOT"
79+
dependencies: {
80+
"mycompany-helper": "mycompany:mycompany-helper:1.4.*"
81+
"mycompany-services": "mycompany:mycompany-services:1.7.*"
82+
"mycompany-crm": "mycompany:mycompany-crm:2.28.*"
83+
}
2184
```
85+
86+
## CompanyCamundalaDevHelper
87+
The `CompanyCamundalaDevHelper` is a helper dedicated for the `company-camundala` project.
88+
89+
See [Development]
90+
91+
```scala
92+
object CompanyCamundalaDevHelper
93+
extends DevCompanyCamundalaHelper:
94+
95+
lazy val apiConfig: ApiConfig = CompanyApiCreator.apiConfig
96+
.copy(
97+
basePath = os.pwd /"00-docs",
98+
tempGitDir = os.pwd / os.up / "git-temp"
99+
)
100+
101+
lazy val devConfig: DevConfig = CompanyDevConfig.config(BuildInfo.name, Seq.empty)
102+
103+
end CompanyCamundalaDevHelper
104+
```
105+
106+
### apiConfig
107+
The `apiConfig` is taken from `CompanyApiCreator.apiConfig` and can be customized.
108+
The `basePath` and the `tempGitDir` must be adjusted, as `company-camundala`
109+
has a different file structure, compared to a project.
110+
111+
### devConfig
112+
Here your `DevConfig` defined in the `CompanyDevConfig.config` method, should work.
113+
The only adjustments are the `projectName` and that no `subProjects` are needed.

00-docs/src/docs/development/projectDev.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Project Development
2-
**Experimental**
32

43
The following chapters describe the tasks to support the project development.
54

@@ -11,6 +10,33 @@ And then you can type `./helper.scala <command>` to get help for a specific comm
1110

1211
The `version` is optional and defaults to `1`.
1312

13+
## helper.scala
14+
This file will be replaced with `./helper.scala update`. However, you need to set there the
15+
subprojects you want to use.
16+
17+
```scala
18+
#!/usr/bin/env -S scala shebang
19+
// DO NOT ADJUST. This file is replaced by `./helper.scala update`.
20+
//> using dep mycompany::mycompany-camundala-helper:0.1.0-SNAPSHOT
21+
22+
import mycompany.camundala.helper.*
23+
24+
lazy val projectName: String = "mycompany-myProject"
25+
lazy val subProjects = Seq(
26+
"accounting",
27+
"hr"
28+
)
29+
30+
@main
31+
def run(command: String, arguments: String*): Unit =
32+
CompanyDevHelper(projectName, subProjects).run(command, arguments*)
33+
```
34+
### subProjects
35+
Compile time can be optimized by using subprojects - this makes the project a bit more complex,
36+
as for each subProject, a SBT module is created.
37+
38+
`./helper.scala update` will generate this file but preserve the project name and subprojects.
39+
1440
## update
1541
Whenever you have changes in the `company-camundala` project or in one of your dependencies,
1642
you can update the project with the following command:
@@ -31,7 +57,8 @@ You will get a warning, but the file will not be replaced.
3157
Creates a new Release for the BPMN project and publishes to the repository(e.g. Artifactory)
3258

3359
@:callout(info)
34-
Adjust the `CompanyDevHelper.publishConfig` configuration.
60+
If you want to provide the documentation on a WebDAV server,
61+
you need a `CompanyDevHelper.devConfig.publishConfig` configuration.
3562

3663
@:@
3764

@@ -66,7 +93,7 @@ The following steps are executed:
6693
Deploys the BPMN project to the local Camunda server and runs the Simulation you're working on.
6794

6895
@:callout(info)
69-
**Be aware** that `CompanyDevHelper.deployConfig` must be defined.
96+
**Be aware** that `CompanyDevHelper.devConfig.postmanConfig` must be defined.
7097

7198
At the moment, only deployment via _Postman Collection_ is supported (using Camunda REST API to deploy).
7299
@:@
@@ -265,7 +292,7 @@ To run the Camunda Server locally, you can use `docker-compose`.
265292
**Precondition**:
266293
- You have to have `docker` and `docker-compose` installed.
267294
- You need to have a `docker-compose.yml` in `dev-company/docker` directory.
268-
- Adjust the `CompanyDevHelper.dockerConfig` configuration.
295+
- Adjust the `CompanyDevHelper.devConfig.dockerConfig` configuration.
269296

270297
@:@
271298

03-api/src/main/scala/camundala/api/ApiConfig.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ object ApiConfig:
9292
end ApiConfig
9393

9494
case class ProjectsConfig(
95-
// Path to your ApiProjectConf - default is os.pwd / PROJECT.conf
96-
projectConfPath: os.RelPath = defaultProjectPath,
97-
// grouped configs per GitRepos - so it is possible to use projects from different Repos
98-
perGitRepoConfigs: Seq[ProjectsPerGitRepoConfig] = Seq.empty
95+
// Path to your ApiProjectConf - default is os.pwd / PROJECT.conf
96+
projectConfPath: os.RelPath = defaultProjectConfigPath,
97+
// grouped configs per GitRepos - so it is possible to use projects from different Repos
98+
perGitRepoConfigs: Seq[ProjectsPerGitRepoConfig] = Seq.empty
9999
):
100100

101101
lazy val isConfigured: Boolean = perGitRepoConfigs.nonEmpty

03-api/src/main/scala/camundala/api/exports.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import camundala.bpmn.shortenName
55
import camundala.domain.*
66

77
val catalogFileName = "catalog.md"
8-
val defaultProjectPath = os.rel / "PROJECT.conf"
8+
val defaultProjectConfigPath = os.rel / "PROJECT.conf"
99

1010
def shortenTag(refIdentShort: String) =
1111
val tag = shortenName(refIdentShort)

04-helper/src/main/scala/camundala/helper/dev/DevCompanyCamundalaHelper.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package camundala.helper.dev
22

3-
import camundala.api.ApiConfig
43
import camundala.helper.dev.company.docs.DocCreator
54
import camundala.helper.dev.publish.PublishHelper
65
import camundala.helper.dev.publish.PublishHelper.*
7-
import camundala.helper.util.{DevConfig, Helpers, PublishConfig}
6+
import camundala.helper.util.{DevConfig, PublishConfig}
87

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

1110
// dev-company/company-camundala/helper.scala
12-
trait DevCompanyCamundalaHelper extends Helpers, DocCreator:
11+
trait DevCompanyCamundalaHelper extends DocCreator:
1312
def devConfig: DevConfig
1413

1514
def runForCompany(command: String, arguments: String*): Unit =
@@ -24,6 +23,8 @@ trait DevCompanyCamundalaHelper extends Helpers, DocCreator:
2423
end match
2524
end runForCompany
2625

26+
protected def publishConfig: Option[PublishConfig] = devConfig.publishConfig
27+
2728
private def runCommand(command: Command, args: Seq[String]): Unit =
2829
command match
2930
case Command.publish if args.size == 1 =>

04-helper/src/main/scala/camundala/helper/dev/DevHelper.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ import scala.util.{Failure, Success, Try}
1212
trait DevHelper:
1313
def apiConfig: ApiConfig
1414
def devConfig: DevConfig
15-
def publishConfig: Option[PublishConfig]
16-
def deployConfig: Option[DeployConfig]
17-
def dockerConfig: DockerConfig
15+
1816
given DevConfig = devConfig
1917
given ApiConfig = apiConfig
20-
given Option[PublishConfig] = publishConfig
2118

2219
def run(command: String, arguments: String*): Unit =
2320
val args = arguments.toSeq
@@ -115,7 +112,7 @@ trait DevHelper:
115112
case Command.deploy =>
116113
args match
117114
case Seq(simulation) =>
118-
deployConfig
115+
devConfig.postmanConfig
119116
.map(DeployHelper(_).deploy(Some(simulation)))
120117
.getOrElse(println("deploy is not supported as there is no deployConfig"))
121118
case other =>
@@ -124,11 +121,11 @@ trait DevHelper:
124121
println(s"Example: $command OpenAccountSimulation")
125122
// docker
126123
case Command.dockerUp =>
127-
DockerHelper(dockerConfig).dockerUp()
124+
DockerHelper(devConfig.dockerConfig).dockerUp()
128125
case Command.dockerStop =>
129-
DockerHelper(dockerConfig).dockerStop()
126+
DockerHelper(devConfig.dockerConfig).dockerStop()
130127
case Command.dockerDown =>
131-
DockerHelper(dockerConfig).dockerDown()
128+
DockerHelper(devConfig.dockerConfig).dockerDown()
132129

133130
private def printBadActivity(command: Command, args: Seq[String]): Unit =
134131
println(s"Invalid arguments for command $command: $args")

0 commit comments

Comments
 (0)