Skip to content

Commit c450c28

Browse files
committed
Restructured Helper - Added DevCompanyHelper.initCompany.
1 parent 90e6788 commit c450c28

35 files changed

+754
-213
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Create Project
2+
**Experimental**
3+
4+
TODO
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Development
2+
3+
## Pre-Requisites
4+
**_Camundala_** is written in _**Scala**_ and provides _Scala DSLs_.
5+
So far we only use it as a _sbt_ projects.
6+
Here is a video to get you started with a Scala dev environment:
7+
[Setting up a dev environment with Coursier](https://www.youtube.com/watch?v=j-H6LSv2z_8&list=PLTx-VKTe8yLxYQfX_eGHCxaTuWvvG28Ml).
8+
9+
There are three phases in the development process:
10+
11+
1. **[Init Company]**
12+
13+
Create the directory structure and common files to get you started with _Camundala_.
14+
15+
2. **[Create Project]**
16+
17+
Create the project directory and the Helper Script for the project development.
18+
19+
3. **[Project Development]**
20+
21+
Tasks to support the project development.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
laika.navigationOrder = [
3+
development.md
4+
initCompany.md
5+
]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Init Company
2+
**Experimental**
3+
4+
Create the directory structure and common files to get you started with _Camundala_.
5+
6+
The Structure of the Process-Projects looks like this:
7+
```
8+
myProject1 myProject2 ...
9+
| | |
10+
company-camundala
11+
|
12+
camundala
13+
```
14+
15+
The idea is that you have a company layer, where you can override Company specific settings.
16+
17+
@:callout(info)
18+
**Be aware** that one of the main advantages is the concept of _Convention over Configuration_.
19+
20+
At the moment not everything is configurable.
21+
22+
So try to stick to the conventions, whenever possible.
23+
@:@
24+
25+
26+
1. Create a directory for your company development:
27+
```bash
28+
mkdir ~/dev-myCompany
29+
```
30+
31+
1. Create `helperCompany.scala` in your company directory.
32+
```bash
33+
cd ~/dev-myCompany
34+
open helperCompany.scala
35+
```
36+
37+
1. Copy the following content to `helperCompany.scala`:
38+
```scala
39+
#!/usr/bin/env -S scala shebang
40+
// DO NOT ADJUST. This file is replaced by `./helper.scala update`.
41+
42+
//> using toolkit 0.5.0
43+
//> using dep io.github.pme123::camundala-helper:${project.version}
44+
45+
import camundala.helper.dev.DevCompanyHelper
46+
47+
@main
48+
def run(command: String, arguments: String*): Unit =
49+
DevCompanyHelper.run(command, arguments*)
50+
```
51+
52+
1. Replace `${project.version}` with _${project.version}_.
53+
54+
1. Make the file executable:
55+
```bash
56+
chmod +x helperCompany.scala
57+
```
58+
59+
1. Create the company directory structure:
60+
```bash
61+
./helperCompany.scala init
62+
```
63+
64+
1. Open the `company-camundala` directory with your IDE (I use Intellij).
65+
1. Import the sbt project. The project should compile without errors.
66+
67+
### Next Step: [Create Project]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Project Development
2+
**Experimental**
3+
4+
TODO

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

Lines changed: 0 additions & 104 deletions
This file was deleted.

04-helper/src/main/scala/camundala/helper/HelperConfig.scala

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package camundala.helper.dev
2+
3+
import camundala.helper.dev.company.InitCompanyGenerator
4+
import camundala.helper.util.{DevConfig, RepoConfig}
5+
6+
import scala.util.{Failure, Success, Try}
7+
8+
object DevCompanyHelper:
9+
10+
def run(command: String, arguments: String*): Unit =
11+
val args = arguments.toSeq
12+
println(s"Running command: $command with args: $args")
13+
Try(Command.valueOf(command)) match
14+
case Success(cmd) =>
15+
runCommand(cmd, args)
16+
case Failure(_) =>
17+
println(s"Command not found: $command")
18+
println("Available commands: " + Command.values.mkString(", "))
19+
end match
20+
end run
21+
22+
private def runCommand(command: Command, args: Seq[String]): Unit =
23+
command match
24+
case Command.`init` =>
25+
initCompany
26+
case Command.project =>
27+
args match
28+
case Seq(projectName) =>
29+
createProject(projectName)
30+
case other =>
31+
println(s"Invalid arguments for command $command: $other")
32+
println("Usage: project <projectName>")
33+
34+
35+
enum Command:
36+
case init, project
37+
38+
def initCompany: Unit =
39+
val companyName = os.pwd.last.replace("dev-", "")
40+
println(s"Init Company $companyName")
41+
given config: DevConfig = InitCompanyGenerator.init(companyName) //, repoConfig)
42+
InitCompanyGenerator().generate
43+
44+
def createCompany(companyName: String) = //, repoConfig: RepoConfig) =
45+
println(s"Create/Update Company: $companyName")
46+
47+
// given config: DevConfig = SetupCompanyGenerator.init(companyName, repoConfig)
48+
49+
// SetupCompanyGenerator().generate
50+
51+
def createProject(projectName: String): Unit =
52+
println(s"Update Project: $projectName")
53+
// SetupGenerator()(using config.setupConfig).generate
54+
end DevCompanyHelper

0 commit comments

Comments
 (0)