Skip to content

Commit e03d92a

Browse files
author
zthomas
committed
updated readme with example logic flow and local dev instructions
1 parent 63287b0 commit e03d92a

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ The best way then to use this is to add an alias, then you can use the CLI as if
2222
## Usage
2323

2424
1) To create a project run `commit0 create [PROJECT_NAME]`
25-
2) A folder will be created and within that update the `commit0.yml` and then run `commit0 generate -l=[LANGUAGE OF CHOICE] eg. go`
25+
2) A folder will be created and within that update the `commit0.yml` and then run `commit0 generate -c <commit0.yml>`
2626
3) You will see that there is now an idl folder created.
2727
4) Within the idl folder modify the the protobuf services generated with your desired methods
28-
5) Go up to the parent directory and re run `commit0 generate -l=[LANGUAGE OF CHOICE]`
28+
5) Go up to the parent directory and re run `commit0 generate -c <commit0.yml>`
2929
6) You will now see a `server` folder navigate to your service folder within that directory and implement the methods generated for it
3030
7) Once you have tested your implementation and are happy with it return to the idl repo push that directory up to git
3131
8) Return to the parent directory and check the depency file, for go it will be the go.mod file remove the lines that point it to your local directory, this will now point it to the version on git that was pushed up previously
@@ -66,13 +66,40 @@ this will create a commit0 executable in your working direcory. To install insta
6666
make install-go
6767
```
6868

69+
Compile a new `commit0` binary in the working directory
70+
```
71+
make build
72+
```
73+
74+
Now you can either add your project directory to your path or just execute it directly
75+
```
76+
mkdir tmp
77+
cd tmp
78+
../commit0 create test-app
79+
cd test-app
80+
../../commit0 generate -c commit0.yml
81+
```
82+
6983
### Architecture
7084
The project is built with GoLang and requires Docker
7185
- /cmd - the CLI command entry points
7286
- /internal/generate
7387
- /internal/config
7488
- /internal/templator - the templating service
7589

90+
Example Flow:
91+
The application starts at `cmd/generate.go`
92+
1. loads all the templates from packr
93+
- TODO: eventually this should be loaded remotely throug a dependency management system
94+
2. loads the config from the commit0.yml config file
95+
3. based on the configs, run the appropriate generators
96+
- templator is passed in to the Generate function for dependency injection
97+
4. each generator (`react/generate.go`, `ci/generate.go` etc) further delegates and actually executes the templating based on the configs passed in.
98+
- `internal/templator/templator.go` is the base class and includes generic templating handling logic
99+
- it CI is required, it'll also call a CI generator and pass in the service specific CI configs
100+
- TODO: templator should be generic and not have any knowledge of the specific templating implementation (go, ci etc), move that logic upstream
101+
5. Depending on the config (`deploy == true` for certain) it'll also run the `Execute` function and actually deploy the infrastructure
102+
76103
### Building locally
77104

78105
As the templates are embeded into the binary you will need to ensure packr2 is installed.

internal/generate/ci/generate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func (e *CIGenerationError) Error() string {
2626
return fmt.Sprintf("Error: %s. Unable to Generate CI/CD Pipeline with config:\n%v\n", e.err, e.config)
2727
}
2828

29+
// TODO shouldn't have to pass in both ciConfig, should be able to
2930
// Generate a CI configuration file based on your language and CI system
3031
func Generate(t *templator.CITemplator, cfg *config.Commit0Config, ciConfig config.CI, basePath string, wg *sync.WaitGroup) error {
3132

@@ -47,7 +48,7 @@ func Generate(t *templator.CITemplator, cfg *config.Commit0Config, ciConfig conf
4748
ciFilename = ".travis.yml"
4849
ciTemp = t.TravisCI
4950
case "github":
50-
ciConfigPath = fmt.Sprintf("%s/%s", basePath, ".github/")
51+
ciConfigPath = fmt.Sprintf("%s/%s", basePath, ".github/workflow/")
5152
ciFilename = "config.yml"
5253
ciTemp = t.CircleCI
5354
default:

0 commit comments

Comments
 (0)