Skip to content

Commit

Permalink
Merge pull request #123 from commitdev/cleanup-and-rename
Browse files Browse the repository at this point in the history
First pass at renaming and cleaning up old stuff
  • Loading branch information
bmonkman committed May 25, 2020
2 parents 5176cd0 + adee8d5 commit f787e1e
Show file tree
Hide file tree
Showing 28 changed files with 231 additions and 133 deletions.
4 changes: 2 additions & 2 deletions .gitignore
@@ -1,9 +1,9 @@
main-packr.go
packrd
/commit0
/zero
.history/
tmp
.vscode
example/
test-reports/
.circleci/config-compiled.yml
.circleci/config-compiled.yml
8 changes: 4 additions & 4 deletions Dockerfile
Expand Up @@ -22,15 +22,15 @@ RUN chmod +x /usr/local/bin/* && \

# Hydrate the dependency cache. This way, if the go.mod or go.sum files do not
# change we can cache the depdency layer without having to reinstall them.
WORKDIR /tmp/commit0
WORKDIR /tmp/zero
COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN make build && \
mv commit0 /usr/local/bin && \
upx --lzma /usr/local/bin/commit0
mv zero /usr/local/bin && \
upx --lzma /usr/local/bin/zero

FROM alpine:3.10
ENV \
Expand All @@ -45,4 +45,4 @@ COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /go/src/github.com/grpc-ecosystem/grpc-gateway ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway
WORKDIR /project

ENTRYPOINT ["/usr/local/bin/commit0"]
ENTRYPOINT ["/usr/local/bin/zero"]
18 changes: 9 additions & 9 deletions Makefile
@@ -1,6 +1,6 @@
VERSION = 0.0.1
BUILD ?=$(shell git rev-parse --short HEAD)
PKG ?=github.com/commitdev/commit0
PKG ?=github.com/commitdev/zero
BUILD_ARGS=-v -ldflags=all="-X ${PKG}/cmd.appVersion=${VERSION} -X ${PKG}/cmd.appBuild=${BUILD}"

check:
Expand All @@ -10,24 +10,24 @@ fmt:
go fmt ./...

build-docker-local:
docker build . -t commit0:v0
docker build . -t zero:v0

build-example-docker: clean-example
mkdir -p example
docker run -v "$(shell pwd)/example:/project" --user $(shell id -u):$(shell id -g) commit0:v0 create "hello-world"
docker run -v "$(shell pwd)/example/hello-world:/project" --user $(shell id -u):$(shell id -g) commit0:v0 generate -l go
docker run -v "$(shell pwd)/example:/project" --user $(shell id -u):$(shell id -g) zero:v0 create "hello-world"
docker run -v "$(shell pwd)/example/hello-world:/project" --user $(shell id -u):$(shell id -g) zero:v0 generate -l go

build:
go build ${BUILD_ARGS}
go build ${BUILD_ARGS}

# Installs the CLI int your GOPATH
install-go:
go build -o ${GOPATH}/bin/commit0
go build -o ${GOPATH}/bin/zero

# CI Commands used on CircleCI
ci-docker-build:
docker build . -t commitdev/commit0:${VERSION_TAG} -t commitdev/commit0:latest
docker build . -t commitdev/zero:${VERSION_TAG} -t commitdev/zero:latest

ci-docker-push:
echo "${DOCKERHUB_PASS}" | docker login -u commitdev --password-stdin
docker push commitdev/commit0:${VERSION_TAG}
docker push commitdev/zero:${VERSION_TAG}
38 changes: 19 additions & 19 deletions OLD-README.md
Expand Up @@ -13,30 +13,30 @@ Status: Proof of Concept
## About Commit0
Commit0 is a project skaffolding framework and ecosystem created to:

1. Maximize knowledge sharing across an organization
1. Maximize knowledge sharing across an organization
2. Easily maintain a state of the art and easily reusable implementations of production grade solutions to recurring problems
3. Re-create the seamless deployment experience offered by PaaS solutions but with a fully open source stack that follows industry best practices

With Commit0:
- Easily deploy and integrate various boilerplate solutions
- Instantly integrate commonly used open source microservices for authentication, user management, file encryption, image resizing etc.
- Instantly integrate commonly used open source microservices for authentication, user management, file encryption, image resizing etc.
- Get a simple Push-To-Deploy workflow that you are accustomed to with popular PaaS solutions [TODO]
- There's no vendor lock-in. It's all implemented with open source tools and deployed to your own cloud provider.

## Commit0 Generator CLI
Commit0 CLI is an opinionated, yet fully modular code generation tool with declarative syntax that allows developers to easily integrate user prompts and interactions.
## Commit0 Generator CLI
Commit0 CLI is an opinionated, yet fully modular code generation tool with declarative syntax that allows developers to easily integrate user prompts and interactions.

Problems we encountered:
Problems we encountered:
- It was tedious to create reusable templates and hard to maintain
- Lack of standardization and integration interface between the templates
- Difficult to integrate individually templated codebases

How we aim to address those issues:
How we aim to address those issues:
- Make templating behaviour simple and declarative
- Clear strategy and guideline around what are clear and reusable templates
- Standardize how templated code should get dependent parameters and start up

This is inspired by:
This is inspired by:
- [Yeoman Generator](https://github.com/yeoman/generator)
- [JHipster](https://github.com/jhipster/generator-jhipster)
- [Boilr](https://github.com/tmrts/boilr)
Expand Down Expand Up @@ -83,18 +83,18 @@ This is a guide on how to configure your project manually with a single file `co
* [output](#template-output)

## Commit0.yaml<a name="commit0-yaml"></a>
Your project config file. It describes the project
Your project config file. It describes the project
Example:
```
name: newProject
context:
context:
cognitoPoolID: xxx
modules:
- source: "github.com/commitdev/commit0-aws-eks-stack"
modules:
- source: "github.com/commitdev/commit0-aws-eks-stack"
output: "infrastructure"
- source: "github.com/zthomas/react-mui-kit"
- source: "github.com/zthomas/react-mui-kit"
output: "web-app"
```
```

## Name<a name="name"></a>
Name of your project. This will be used to name the github repos as well as in other parts of the generated code.
Expand All @@ -105,7 +105,7 @@ Required | True
Type | String

## Context<a name="context"></a>
A key value map of global context parameters to use in the templates.
A key value map of global context parameters to use in the templates.

[]() | |
--- | ---
Expand Down Expand Up @@ -159,13 +159,13 @@ The module config file. You can configure how the templating engine should proce
Example:
```
name: react-mui-kit
template:
template:
extension: '.tmplt'
delimiters:
delimiters:
- '<%'
- '%>'
output: web-app
```
```

## Name<a name="module-name"></a>
Name of your module. This will be used as the default module directory as well as a display name in the prompts.
Expand Down Expand Up @@ -207,7 +207,7 @@ Required | False
Type | Map[String]

## Output<a name="template-output"></a>
The default template output directory that you want the template engine to write to. This will be overwritten by the
The default template output directory that you want the template engine to write to. This will be overwritten by the

[]() | |
--- | ---
Expand Down Expand Up @@ -268,7 +268,7 @@ cd test-app

To run a single test for development
```
go test -run TestGenerateModules "github.com/commitdev/commit0/internal/generate" -v
go test -run TestGenerateModules "github.com/commitdev/zero/internal/generate" -v
```

### Building locally
Expand Down
22 changes: 22 additions & 0 deletions cmd/apply.go
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/commitdev/zero/configs"
"github.com/spf13/cobra"
)

var applyConfigPath string

func init() {
applyCmd.PersistentFlags().StringVarP(&applyConfigPath, "config", "c", configs.CommitYml, "config path")

rootCmd.AddCommand(applyCmd)
}

var applyCmd = &cobra.Command{
Use: "apply",
Short: "Execute modules to create projects, infrastructure, etc.",
Run: func(cmd *cobra.Command, args []string) {

},
}
8 changes: 7 additions & 1 deletion cmd/check.go
Expand Up @@ -73,6 +73,12 @@ func getSemver(req requirement, out []byte) (*semver.Version, error) {
fmt.Sprintf("Try running %s %s locally and checking it works.", req.command, strings.Join(req.args, " ")),
}
}

// Default patch version number to 0 if it doesn't exist
if v[3] == "" {
v[3] = "0"
}

versionString := fmt.Sprintf("%s.%s.%s", v[1], v[2], v[3])
version, err := semver.NewVersion(versionString)
if err != nil {
Expand Down Expand Up @@ -125,7 +131,7 @@ var checkCmd = &cobra.Command{
name: "jq\t\t",
command: "jq",
args: []string{"--version"},
regexStr: `jq-(0|[1-9]\d*)\.(0|[1-9]\d*)-(0|[1-9]\d*)`,
regexStr: `jq-(0|[1-9]\d*)\.(0|[1-9]\d*)\-?(0|[1-9]\d*)?`,
minVersion: "1.5.0",
docsURL: "https://stedolan.github.io/jq/download/",
},
Expand Down
20 changes: 10 additions & 10 deletions cmd/create.go
@@ -1,27 +1,27 @@
package cmd

import (
"github.com/commitdev/commit0/internal/config"
"github.com/commitdev/commit0/internal/context"
"github.com/commitdev/commit0/pkg/util/exit"
"github.com/commitdev/zero/configs"
"github.com/commitdev/zero/internal/config"
"github.com/commitdev/zero/internal/generate"
"github.com/spf13/cobra"
)

var createConfigPath string

func init() {
createCmd.PersistentFlags().StringVarP(&createConfigPath, "config", "c", configs.CommitYml, "config path")

rootCmd.AddCommand(createCmd)
}

var createCmd = &cobra.Command{
Use: "create",
Short: "Create new project with provided name.",
Short: "Create directories and render templates based on included modules.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
exit.Fatal("Project name cannot be empty!")
}

projectName := args[0]
context.Create(projectName, "./")
cfg := config.LoadGeneratorConfig(createConfigPath)

config.CreateExample(projectName)
generate.GenerateModules(cfg)
},
}
27 changes: 0 additions & 27 deletions cmd/generate.go

This file was deleted.

27 changes: 27 additions & 0 deletions cmd/init.go
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/commitdev/zero/internal/config"
"github.com/commitdev/zero/internal/context"
"github.com/commitdev/zero/pkg/util/exit"
"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(initCmd)
}

var initCmd = &cobra.Command{
Use: "init",
Short: "Create new project with provided name and initialize configuration based on user input.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
exit.Fatal("Project name cannot be empty!")
}

projectName := args[0]
context.Create(projectName, "./")

config.CreateExample(projectName)
},
}
4 changes: 2 additions & 2 deletions cmd/create_test.go → cmd/init_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
)

func TestCreateWorks(t *testing.T) {
func TestInitWorks(t *testing.T) {
// @TODO : Figure out a way to test this
// tmpdir, err := ioutil.TempDir("", "commit0-")
// if err != nil {
Expand All @@ -25,6 +25,6 @@ func TestCreateWorks(t *testing.T) {
// }

// if st.Size() == 0 {
// t.Fatalf("commit0.yml is empty")
// t.Fatalf("zero.yml is empty")
// }
}
2 changes: 1 addition & 1 deletion cmd/version.go
Expand Up @@ -17,7 +17,7 @@ func init() {

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of commit0",
Short: "Print the version number of zero",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("version: %v\n", appVersion)
fmt.Printf("build: %v\n", appBuild)
Expand Down
4 changes: 2 additions & 2 deletions cmd/commit0.go → cmd/zero.go
Expand Up @@ -8,8 +8,8 @@ import (
)

var rootCmd = &cobra.Command{
Use: "commit0",
Short: "Commit0 is a modular service generator.",
Use: "zero",
Short: "zero gets you to writing code quicker.",
Long: `TODO`,
Run: func(cmd *cobra.Command, args []string) {
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/commit0_ui.go → cmd/zero_ui.go
@@ -1,17 +1,17 @@
package cmd

import (
"github.com/commitdev/commit0/internal/api"
"github.com/commitdev/zero/internal/api"
"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(commit0api)
rootCmd.AddCommand(zeroApi)
}

var commit0api = &cobra.Command{
var zeroApi = &cobra.Command{
Use: "ui",
Short: "Run Commit0 Api",
Short: "Run zero Api",
Run: func(cmd *cobra.Command, args []string) {
api.Commit0Api()
},
Expand Down
4 changes: 2 additions & 2 deletions configs/configs.go
Expand Up @@ -2,7 +2,7 @@ package configs

const (
TemplatesDir = "tmp/templates"
CommitYml = "commit0.yml"
IgnoredPaths = "(?i)commit0.module.yml|.git/"
CommitYml = "zero.yml"
IgnoredPaths = "(?i)zero.module.yml|.git/"
TemplateExtn = ".tmpl"
)

0 comments on commit f787e1e

Please sign in to comment.