From e03d92ae4bca672fd4c5d82c4795a1d2b0b7c6cd Mon Sep 17 00:00:00 2001 From: zthomas Date: Sat, 9 Nov 2019 13:59:50 -0800 Subject: [PATCH] updated readme with example logic flow and local dev instructions --- README.md | 31 +++++++++++++++++++++++++++++-- internal/generate/ci/generate.go | 3 ++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7a2aa1299..32f526316 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ The best way then to use this is to add an alias, then you can use the CLI as if ## Usage 1) To create a project run `commit0 create [PROJECT_NAME]` -2) A folder will be created and within that update the `commit0.yml` and then run `commit0 generate -l=[LANGUAGE OF CHOICE] eg. go` +2) A folder will be created and within that update the `commit0.yml` and then run `commit0 generate -c ` 3) You will see that there is now an idl folder created. 4) Within the idl folder modify the the protobuf services generated with your desired methods -5) Go up to the parent directory and re run `commit0 generate -l=[LANGUAGE OF CHOICE]` +5) Go up to the parent directory and re run `commit0 generate -c ` 6) You will now see a `server` folder navigate to your service folder within that directory and implement the methods generated for it 7) Once you have tested your implementation and are happy with it return to the idl repo push that directory up to git 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,6 +66,20 @@ this will create a commit0 executable in your working direcory. To install insta make install-go ``` +Compile a new `commit0` binary in the working directory +``` +make build +``` + +Now you can either add your project directory to your path or just execute it directly +``` +mkdir tmp +cd tmp +../commit0 create test-app +cd test-app +../../commit0 generate -c commit0.yml +``` + ### Architecture The project is built with GoLang and requires Docker - /cmd - the CLI command entry points @@ -73,6 +87,19 @@ The project is built with GoLang and requires Docker - /internal/config - /internal/templator - the templating service +Example Flow: +The application starts at `cmd/generate.go` +1. loads all the templates from packr + - TODO: eventually this should be loaded remotely throug a dependency management system +2. loads the config from the commit0.yml config file +3. based on the configs, run the appropriate generators + - templator is passed in to the Generate function for dependency injection +4. each generator (`react/generate.go`, `ci/generate.go` etc) further delegates and actually executes the templating based on the configs passed in. + - `internal/templator/templator.go` is the base class and includes generic templating handling logic + - it CI is required, it'll also call a CI generator and pass in the service specific CI configs + - TODO: templator should be generic and not have any knowledge of the specific templating implementation (go, ci etc), move that logic upstream +5. Depending on the config (`deploy == true` for certain) it'll also run the `Execute` function and actually deploy the infrastructure + ### Building locally As the templates are embeded into the binary you will need to ensure packr2 is installed. diff --git a/internal/generate/ci/generate.go b/internal/generate/ci/generate.go index 459f5a04f..bc0a44ddf 100644 --- a/internal/generate/ci/generate.go +++ b/internal/generate/ci/generate.go @@ -26,6 +26,7 @@ func (e *CIGenerationError) Error() string { return fmt.Sprintf("Error: %s. Unable to Generate CI/CD Pipeline with config:\n%v\n", e.err, e.config) } +// TODO shouldn't have to pass in both ciConfig, should be able to // Generate a CI configuration file based on your language and CI system func Generate(t *templator.CITemplator, cfg *config.Commit0Config, ciConfig config.CI, basePath string, wg *sync.WaitGroup) error { @@ -47,7 +48,7 @@ func Generate(t *templator.CITemplator, cfg *config.Commit0Config, ciConfig conf ciFilename = ".travis.yml" ciTemp = t.TravisCI case "github": - ciConfigPath = fmt.Sprintf("%s/%s", basePath, ".github/") + ciConfigPath = fmt.Sprintf("%s/%s", basePath, ".github/workflow/") ciFilename = "config.yml" ciTemp = t.CircleCI default: