Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into feat/g…
Browse files Browse the repository at this point in the history
…en_id/preamble

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
Fazt01 committed Aug 16, 2024
2 parents add203c + f47a1fb commit 591ed8d
Show file tree
Hide file tree
Showing 58 changed files with 34 additions and 5,285 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ How to release a new version:

## [Unreleased]
### Added
- Use `debug.ReadBuildInfo` to get correct version.
- Print to stderr on error.
- `gen_id` now includes a comment at the top of the generated file to warn developers that the file is, in fact, generated.

### Removed
- `openapi compose`, `repo init`, `repo template` commands.

## [0.4.0] - 2023-03-27
### Added
- Support for string IDs.
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @strvcom/go
* @TomasKocman @bafko @Fazt01 @xburda4
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ GO := $(shell which go)

APP_VERSION ?= "v0.0.0"

.PHONY:
run \
test \
build

.PHONY: all
all: fmt vet build

.PHONY: fmt
fmt:
$(GO) fmt ./...

.PHONY: vet
vet:
$(GO) vet ./...

.PHONY: run
run: RUN_ARGS=--help
run: fmt vet
$(GO) run ./cmd/tea $(RUN_ARGS)

.PHONY: test
test: generate
$(GO) test ./... -cover

.PHONY: build
build: BUILD_OUTPUT=./bin/tea
build: generate
CGO_ENABLED=0 $(GO) build -ldflags "-X main.version=$(APP_VERSION)" -mod=readonly -o $(BUILD_OUTPUT) ./cmd/tea

.PHONY: generate
generate:
$(GO) generate ./...
50 changes: 0 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,56 +53,6 @@ type (
```
After triggering `go generate ./...` within an app, methods `MarshalText` and `UnmarshalText` along with other useful functions are generated.

### openapi
This command provides a set of tools to manage OpenAPI specifications.

Subcommand `compose` merges multiple OpenAPI specifications into a single schema. Example:
```shell
$ tea openapi compose -i ./api/openapi_compose.yaml -o ./api/openapi.yaml
```

This command can also be used as an embedded go generator to embed OpenAPI specification. Example:

```go
import _ "embed
//go:generate tea openapi compose -i ./openapi_compose.yaml -o ./openapi.yaml
//go:embed openapi.yaml
var OpenAPI string
```
After triggering `go generate ./...` within an app, `openapi.yaml` is generated. Afterthat, it is embedded into the app during build.
### repo
This command provides a set of tools to manage a local Go repository. Note that it is required to have a configured `.cup` file in the root of the repository
you wish to configure or have one in the home directory as a default.
Subcommand `template` finds and executes template files and folders in the repository. It is useful for creating a template repository
which will be later used for the creation of another project.
By default, it executes all files ending with `*.template` in the local directory and its subdirectories. Example:
```shell
$ tea repo template --recursive
```
.cup:
```yaml
repo:
template:
module: test
author: Jane Doe
values:
- name: config
data:
port: 8080
version: 0.1.0
```
test.template:
```yaml
module: {{ .Module }}
author: {{ .Author }}
config:
port: "{{ .Values.config.port }}"
version: {{ .Version }}
```
[release]: https://img.shields.io/github/v/release/strvcom/strv-backend-go-tea
[codecov]: https://codecov.io/gh/strvcom/strv-backend-go-tea
[codecov-img]: https://codecov.io/gh/strvcom/strv-backend-go-tea/branch/master/graph/badge.svg?token=A7QFX32CFF
Expand Down
11 changes: 2 additions & 9 deletions cmd/tea/gen_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"errors"
"fmt"
"go/ast"
"go/parser"
Expand Down Expand Up @@ -39,14 +38,8 @@ Example:
RefreshToken uint64
)
`,
Run: func(cmd *cobra.Command, args []string) {
if err := runGenerateIDs(genIDOptions.SourceFilePath, genIDOptions.OutputFilePath); err != nil {
e := &cmderrors.CommandError{}
if errors.As(err, &e) {
os.Exit(e.Code)
}
os.Exit(-1)
}
RunE: func(cmd *cobra.Command, args []string) error {
return runGenerateIDs(genIDOptions.SourceFilePath, genIDOptions.OutputFilePath)
},
}

Expand Down
12 changes: 10 additions & 2 deletions cmd/tea/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package main

import "os"
import (
"errors"
"os"

cmderrors "go.strv.io/tea/pkg/errors"
)

func main() {
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
if err := rootCmd.Execute(); err != nil {
// TODO: Log the error.
e := &cmderrors.CommandError{}
if errors.As(err, &e) {
os.Exit(e.Code)
}
os.Exit(1)
}
}
26 changes: 0 additions & 26 deletions cmd/tea/oapi.go

This file was deleted.

105 changes: 0 additions & 105 deletions cmd/tea/oapi_compose.go

This file was deleted.

75 changes: 0 additions & 75 deletions cmd/tea/oapi_compose_test.go

This file was deleted.

28 changes: 0 additions & 28 deletions cmd/tea/repo.go

This file was deleted.

Loading

0 comments on commit 591ed8d

Please sign in to comment.