1

feat: generate readme from configuration

This commit is contained in:
Mya 2023-12-31 11:12:54 -06:00
parent 7b46255e57
commit be539ea4e8
Signed by: mya
GPG Key ID: 4DFBA0F91AC3544A
6 changed files with 256 additions and 16 deletions

20
Makefile Normal file
View File

@ -0,0 +1,20 @@
define HELP_TEXT
Welcome!
Targets:
help provides help text
legal prepends license to source code
generate generates code for client library
endef
export HELP_TEXT
help:
@echo "$$HELP_TEXT"
legal: .legal
.legal:
@addlicense -f ./legal/header.txt -skip yaml -skip yml .
generate:
@go run ./scripts/gen-readme | prettier --parser markdown > README.md

View File

@ -1,14 +1,16 @@
<br/>
<br/>
<h3 align="center">⚒️ Builds ⚒️</h3>
<h3 align="center">⚒️ Libraries ⚒️</h3>
<div align="center">
| Language | Library | CI Status |
|----------|-------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| Protobuf | [licensing/proto](https://code.pitz.tech/licensing/proto) | [![status-badge](https://build.pitz.tech/api/badges/1/status.svg)](https://build.pitz.tech/repos/1) |
| Golang | [licensing/api-go](https://code.pitz.tech/licensing/api-go) | [![status-badge](https://build.pitz.tech/api/badges/2/status.svg)](https://build.pitz.tech/repos/2) |
| Language | Repository | Build Pipeline |
| -------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| Protobuf | [licensing/proto](https://code.pitz.tech/licensing/proto) | [![status-badge](https://build.pitz.tech/api/badges/1/status.svg)](https://build.pitz.tech/repos/1) |
| Golang | [licensing/api-go](https://code.pitz.tech/licensing/api-go) | [![status-badge](https://build.pitz.tech/api/badges/2/status.svg)](https://build.pitz.tech/repos/2) |
| Rust | [licensing/api-rust](https://code.pitz.tech/licensing/api-rust) | [![status-badge](https://build.pitz.tech/api/badges//status.svg)](https://build.pitz.tech/repos/) |
| NodeJS | [licensing/api-node](https://code.pitz.tech/licensing/api-node) | [![status-badge](https://build.pitz.tech/api/badges//status.svg)](https://build.pitz.tech/repos/) |
</div>
@ -17,17 +19,20 @@
<h3 align="center">⚒️ Tools and Technologies ⚒️</h3>
<p align="center">
<img width="96" height="64" alt="Git" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/git/git-plain-wordmark.svg" />&nbsp;
<img width="96" height="64" alt="Go" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/go/go-original-wordmark.svg" />&nbsp;
<img width="96" height="64" alt="NodeJS" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/nodejs/nodejs-original-wordmark.svg" />&nbsp;
<img width="96" height="64" alt="TypeScript" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/typescript/typescript-original.svg" />
<br/>
<img width="96" height="64" alt="SQLite" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/sqlite/sqlite-original-wordmark.svg" />&nbsp;
<img width="96" height="64" alt="PostgreSQL" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/postgresql/postgresql-original-wordmark.svg" />&nbsp;
<img width="96" height="64" alt="Redis" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/redis/redis-original-wordmark.svg" />
<br/>
<img width="96" height="64" alt="Prometheus" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/prometheus/prometheus-original-wordmark.svg" />
<img width="96" height="64" alt="Git" title="Git" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/git/git-plain.svg" />&nbsp;
<br/>
<img width="96" height="64" alt="Go" title="Go" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/go/go-original.svg" />&nbsp;
<img width="96" height="64" alt="Rust" title="Rust" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/rust/rust-plain.svg" />&nbsp;
<img width="96" height="64" alt="NodeJS" title="NodeJS" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/nodejs/nodejs-original.svg" />&nbsp;
<img width="96" height="64" alt="TypeScript" title="TypeScript" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/typescript/typescript-original.svg" />&nbsp;
<br/>
<img width="96" height="64" alt="SQLite" title="SQLite" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/sqlite/sqlite-original.svg" />&nbsp;
<img width="96" height="64" alt="PostgreSQL" title="PostgreSQL" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/postgresql/postgresql-original.svg" />&nbsp;
<img width="96" height="64" alt="Redis" title="Redis" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/redis/redis-original.svg" />&nbsp;
<br/>
<img width="96" height="64" alt="Prometheus" title="Prometheus" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/prometheus/prometheus-original.svg" />&nbsp;
<img width="96" height="64" alt="Grafana" title="Grafana" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/grafana/grafana-original.svg" />&nbsp;
<br/>
</p>
<br/>
<br/>

18
go.mod Normal file
View File

@ -0,0 +1,18 @@
module code.pitz.tech/licensing/.profile
go 1.20
require github.com/Masterminds/sprig/v3 v3.2.3
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
golang.org/x/crypto v0.3.0 // indirect
)

62
go.sum Normal file
View File

@ -0,0 +1,62 @@
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

2
legal/header.txt Normal file
View File

@ -0,0 +1,2 @@
Copyright (C) {{ .Year }} The Licensing Authors
SPDX-License-Identifier: MIT

133
scripts/gen-readme/main.go Normal file
View File

@ -0,0 +1,133 @@
// Copyright (C) 2023 The Licensing Authors
// SPDX-License-Identifier: MIT
package main
import (
"flag"
"os"
"text/template"
"github.com/Masterminds/sprig/v3"
)
const readme = `
{{- $gitea := .BaseURL.Gitea -}}
{{- $woodpecker := .BaseURL.Woodpecker -}}
<br/>
<br/>
<h3 align="center"> Libraries </h3>
<div align="center">
| Language | Repository | Build Pipeline |
|----------|------------|----------------|
{{- range .Libraries }}
| {{ .Language }} | [{{ .Repository }}]({{ $gitea }}/{{ .Repository }}) | [![status-badge]({{ $woodpecker }}/api/badges/{{ .Build }}/status.svg)]({{ $woodpecker }}/repos/{{ .Build }}) |
{{- end }}
</div>
<br/>
<h3 align="center"> Tools and Technologies </h3>
<p align="center">
{{- range .Tools }}
{{- range . }}
<img width="96" height="64" alt="{{ .Name }}" title="{{ .Name }}" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/{{ .Devicon }}.svg" />&nbsp;
{{- end }}
<br/>
{{- end }}
</p>
<br/>
`
type BaseURL struct {
Gitea string
Woodpecker string
}
type Library struct {
Language string
Repository string
Build string
}
type Tool struct {
Name string
Devicon string
}
type TemplateData struct {
BaseURL BaseURL
Libraries []Library
Tools [][]Tool
}
func main() {
cli := flag.NewFlagSet("gen-readme", flag.ExitOnError)
cli.SetOutput(os.Stderr)
output := cli.String("", "-", "")
err := cli.Parse(os.Args[1:])
if err != nil {
panic(err)
}
out := os.Stdout
if output != nil && *output != "" && *output != "-" {
out, err = os.Create(*output)
if err != nil {
panic(err)
}
defer out.Close()
}
t := template.Must(
template.New("readme").
Funcs(sprig.TxtFuncMap()).
Parse(readme),
)
err = t.Execute(out, TemplateData{
BaseURL: BaseURL{
Gitea: "https://code.pitz.tech",
Woodpecker: "https://build.pitz.tech",
},
Libraries: []Library{
{"Protobuf", "licensing/proto", "1"},
{"Golang", "licensing/api-go", "2"},
{"Rust", "licensing/api-rust", ""},
{"NodeJS", "licensing/api-node", ""},
},
Tools: [][]Tool{
{
{"Git", "git/git-plain"},
},
{
{"Go", "go/go-original"},
{"Rust", "rust/rust-plain"},
{"NodeJS", "nodejs/nodejs-original"},
{"TypeScript", "typescript/typescript-original"},
},
{
{"SQLite", "sqlite/sqlite-original"},
{"PostgreSQL", "postgresql/postgresql-original"},
{"Redis", "redis/redis-original"},
},
{
{"Prometheus", "prometheus/prometheus-original"},
{"Grafana", "grafana/grafana-original"},
},
},
})
if err != nil {
panic(err)
}
}