Skip to content

Commit

Permalink
Restructured Helper - Added DevCompanyHelper.initCompany.
Browse files Browse the repository at this point in the history
  • Loading branch information
pme123 committed Dec 10, 2024
1 parent 90e6788 commit c450c28
Show file tree
Hide file tree
Showing 35 changed files with 754 additions and 213 deletions.
4 changes: 4 additions & 0 deletions 00-documentation/src/docs/helper/createProject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Create Project
**Experimental**

TODO
21 changes: 21 additions & 0 deletions 00-documentation/src/docs/helper/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Development

## Pre-Requisites
**_Camundala_** is written in _**Scala**_ and provides _Scala DSLs_.
So far we only use it as a _sbt_ projects.
Here is a video to get you started with a Scala dev environment:
[Setting up a dev environment with Coursier](https://www.youtube.com/watch?v=j-H6LSv2z_8&list=PLTx-VKTe8yLxYQfX_eGHCxaTuWvvG28Ml).

There are three phases in the development process:

1. **[Init Company]**

Create the directory structure and common files to get you started with _Camundala_.

2. **[Create Project]**

Create the project directory and the Helper Script for the project development.

3. **[Project Development]**

Tasks to support the project development.
5 changes: 5 additions & 0 deletions 00-documentation/src/docs/helper/directory.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

laika.navigationOrder = [
development.md
initCompany.md
]
67 changes: 67 additions & 0 deletions 00-documentation/src/docs/helper/initCompany.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Init Company
**Experimental**

Create the directory structure and common files to get you started with _Camundala_.

The Structure of the Process-Projects looks like this:
```
myProject1 myProject2 ...
| | |
company-camundala
|
camundala
```

The idea is that you have a company layer, where you can override Company specific settings.

@:callout(info)
**Be aware** that one of the main advantages is the concept of _Convention over Configuration_.

At the moment not everything is configurable.

So try to stick to the conventions, whenever possible.
@:@


1. Create a directory for your company development:
```bash
mkdir ~/dev-myCompany
```

1. Create `helperCompany.scala` in your company directory.
```bash
cd ~/dev-myCompany
open helperCompany.scala
```

1. Copy the following content to `helperCompany.scala`:
```scala
#!/usr/bin/env -S scala shebang
// DO NOT ADJUST. This file is replaced by `./helper.scala update`.

//> using toolkit 0.5.0
//> using dep io.github.pme123::camundala-helper:${project.version}

import camundala.helper.dev.DevCompanyHelper

@main
def run(command: String, arguments: String*): Unit =
DevCompanyHelper.run(command, arguments*)
```

1. Replace `${project.version}` with _${project.version}_.

1. Make the file executable:
```bash
chmod +x helperCompany.scala
```

1. Create the company directory structure:
```bash
./helperCompany.scala init
```

1. Open the `company-camundala` directory with your IDE (I use Intellij).
1. Import the sbt project. The project should compile without errors.

### Next Step: [Create Project]
4 changes: 4 additions & 0 deletions 00-documentation/src/docs/helper/projectDev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Project Development
**Experimental**

TODO
104 changes: 0 additions & 104 deletions 04-helper/src/main/scala/camundala/helper/DevHelper.scala

This file was deleted.

7 changes: 0 additions & 7 deletions 04-helper/src/main/scala/camundala/helper/HelperConfig.scala

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package camundala.helper.dev

import camundala.helper.dev.company.InitCompanyGenerator
import camundala.helper.util.{DevConfig, RepoConfig}

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

object DevCompanyHelper:

def run(command: String, arguments: String*): Unit =
val args = arguments.toSeq
println(s"Running command: $command with args: $args")
Try(Command.valueOf(command)) match
case Success(cmd) =>
runCommand(cmd, args)
case Failure(_) =>
println(s"Command not found: $command")
println("Available commands: " + Command.values.mkString(", "))
end match
end run

private def runCommand(command: Command, args: Seq[String]): Unit =
command match
case Command.`init` =>
initCompany
case Command.project =>
args match
case Seq(projectName) =>
createProject(projectName)
case other =>
println(s"Invalid arguments for command $command: $other")
println("Usage: project <projectName>")


enum Command:
case init, project

def initCompany: Unit =
val companyName = os.pwd.last.replace("dev-", "")
println(s"Init Company $companyName")
given config: DevConfig = InitCompanyGenerator.init(companyName) //, repoConfig)
InitCompanyGenerator().generate

def createCompany(companyName: String) = //, repoConfig: RepoConfig) =
println(s"Create/Update Company: $companyName")

// given config: DevConfig = SetupCompanyGenerator.init(companyName, repoConfig)

// SetupCompanyGenerator().generate

def createProject(projectName: String): Unit =
println(s"Update Project: $projectName")
// SetupGenerator()(using config.setupConfig).generate
end DevCompanyHelper
Loading

0 comments on commit c450c28

Please sign in to comment.