mirror of
https://github.com/foomo/sesamy-cli.git
synced 2025-10-16 12:35:36 +00:00
feat: add schema
This commit is contained in:
parent
c251bcf83d
commit
c8c93dbfbe
14
Makefile
14
Makefile
@ -1,6 +1,10 @@
|
||||
.DEFAULT_GOAL:=help
|
||||
-include .makerc
|
||||
|
||||
# --- Config -----------------------------------------------------------------
|
||||
|
||||
export PATH := bin:$(PATH)
|
||||
|
||||
# --- Targets -----------------------------------------------------------------
|
||||
|
||||
# This allows us to accept extra arguments
|
||||
@ -12,16 +16,16 @@
|
||||
.husky:
|
||||
@if ! command -v husky &> /dev/null; then \
|
||||
echo "ERROR: missing executeable 'husky', please run:"; \
|
||||
echo "\n$ go install github.com/go-courier/husky/cmd/husky@latest\n"; \
|
||||
echo "\n$ make brew\n"; \
|
||||
fi
|
||||
@git config core.hooksPath .husky
|
||||
|
||||
## === Tasks ===
|
||||
|
||||
.PHONY: schema
|
||||
## Open go schemas
|
||||
schema:
|
||||
@helm schema-gen sesamy.yaml > sesamy.schema.json
|
||||
.PHONY: brew
|
||||
## Install project binaries
|
||||
brew:
|
||||
@ownbrew install
|
||||
|
||||
.PHONY: doc
|
||||
## Open go docs
|
||||
|
||||
5
go.mod
5
go.mod
@ -7,6 +7,7 @@ require (
|
||||
github.com/foomo/go v0.0.3
|
||||
github.com/foomo/gocontemplate v0.1.4
|
||||
github.com/foomo/sesamy-go v0.4.0
|
||||
github.com/invopop/jsonschema v0.12.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
@ -28,6 +29,8 @@ require (
|
||||
cloud.google.com/go/auth v0.9.8 // indirect
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.5.2 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/containerd/console v1.0.3 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
@ -45,6 +48,7 @@ require (
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/lithammer/fuzzysearch v1.1.8 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
@ -56,6 +60,7 @@ require (
|
||||
github.com/spf13/cast v1.6.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
|
||||
|
||||
11
go.sum
11
go.sum
@ -24,6 +24,10 @@ github.com/MarvinJWendt/testza v0.4.2/go.mod h1:mSdhXiKH8sg/gQehJ63bINcCKp7RtYew
|
||||
github.com/MarvinJWendt/testza v0.5.2 h1:53KDo64C1z/h/d/stCYCPY69bt/OSwjq5KpFNwi+zB4=
|
||||
github.com/MarvinJWendt/testza v0.5.2/go.mod h1:xu53QFE5sCdjtMCKk8YMQ2MnymimEctc4n3EjyIYvEY=
|
||||
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
|
||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
@ -98,8 +102,11 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
|
||||
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
|
||||
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
|
||||
@ -116,6 +123,8 @@ github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8
|
||||
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
@ -183,6 +192,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/wissance/stringFormatter v1.2.0 h1:lB0zcJkTA1O4Eb2qSTJmyapla/LihQt6NpJLghwWSb0=
|
||||
github.com/wissance/stringFormatter v1.2.0/go.mod h1:H7Mz15+5i8ypmv6bLknM/uD+U1teUW99PlW0DNCNscA=
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||
|
||||
39
main_test.go
Normal file
39
main_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
testingx "github.com/foomo/go/testing"
|
||||
tagx "github.com/foomo/go/testing/tag"
|
||||
"github.com/foomo/sesamy-cli/pkg/config"
|
||||
"github.com/invopop/jsonschema"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestConfig(t *testing.T) {
|
||||
testingx.Tags(t, tagx.Short)
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
|
||||
reflector := new(jsonschema.Reflector)
|
||||
require.NoError(t, reflector.AddGoComments("github.com/foomo/sesamy-cli", "./"))
|
||||
schema := reflector.Reflect(&config.Config{})
|
||||
actual, err := json.MarshalIndent(schema, "", " ")
|
||||
require.NoError(t, err)
|
||||
|
||||
filename := path.Join(cwd, "sesamy.schema.json")
|
||||
expected, err := os.ReadFile(filename)
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
if !assert.Equal(t, string(expected), string(actual)) {
|
||||
require.NoError(t, os.WriteFile(filename, actual, 0600))
|
||||
}
|
||||
}
|
||||
16
ownbrew.yaml
Normal file
16
ownbrew.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/foomo/ownbrew/refs/tags/v0.1.0/ownbrew.schema.json
|
||||
version: '1.0'
|
||||
|
||||
binDir: "bin"
|
||||
tapDir: ".ownbrew/tap"
|
||||
tempDir: ".ownbrew/tmp"
|
||||
cellarDir: ".ownbrew/bin"
|
||||
packages:
|
||||
## https://github.com/golangci/golangci-lint/releases
|
||||
- name: golangci-lint
|
||||
tap: foomo/tap/golangci/golangci-lint
|
||||
version: 1.61.0
|
||||
## https://github.com/go-courier/husky/releases
|
||||
- name: husky
|
||||
tap: foomo/tap/go-courier/husky
|
||||
version: 1.8.1
|
||||
@ -1,18 +1,30 @@
|
||||
package config
|
||||
|
||||
type Config struct {
|
||||
Version string `json:"version" yaml:"version"`
|
||||
RedactVisitorIP bool `json:"redactVisitorIp" yaml:"redactVisitorIp"`
|
||||
GoogleTag GoogleTag `json:"googleTag" yaml:"googleTag"`
|
||||
GoogleAPI GoogleAPI `json:"googleAPI" yaml:"googleAPI"`
|
||||
// Config version
|
||||
Version string `json:"version" yaml:"version" jsonschema:"required"`
|
||||
// Globally redact visitor ip
|
||||
RedactVisitorIP bool `json:"redactVisitorIp" yaml:"redactVisitorIp"`
|
||||
// Google Tag settings
|
||||
GoogleTag GoogleTag `json:"googleTag" yaml:"googleTag"`
|
||||
// Google API settings
|
||||
GoogleAPI GoogleAPI `json:"googleApi" yaml:"googleApi"`
|
||||
// Google Tag Manager settings
|
||||
GoogleTagManager GoogleTagManager `json:"googleTagManager" yaml:"googleTagManager"`
|
||||
// Providers
|
||||
GoogleAds GoogleAds `json:"googleAds" yaml:"googleAds"`
|
||||
Cookiebot Cookiebot `json:"cookiebot" yaml:"cookiebot"`
|
||||
GoogleAnalytics GoogleAnalytics `json:"googleAnalytics" yaml:"googleAnalytics"`
|
||||
// Google Ads provider settings
|
||||
GoogleAds GoogleAds `json:"googleAds" yaml:"googleAds"`
|
||||
// CookieBot provider settings
|
||||
Cookiebot Cookiebot `json:"cookiebot" yaml:"cookiebot"`
|
||||
// Google Analytics provider settings
|
||||
GoogleAnalytics GoogleAnalytics `json:"googleAnalytics" yaml:"googleAnalytics"`
|
||||
// Conversion Linker provider settings
|
||||
ConversionLinker ConversionLinker `json:"conversionLinker" yaml:"conversionLinker"`
|
||||
Facebook Facebook `json:"facebook" yaml:"facebook"`
|
||||
Emarsys Emarsys `json:"emarsys" yaml:"emarsys"`
|
||||
Tracify Tracify `json:"tracify" yaml:"tracify"`
|
||||
Umami Umami `json:"umami" yaml:"umami"`
|
||||
// Facebook provider settings
|
||||
Facebook Facebook `json:"facebook" yaml:"facebook"`
|
||||
// Emarsys provider settings
|
||||
Emarsys Emarsys `json:"emarsys" yaml:"emarsys"`
|
||||
// Tracify provider settings
|
||||
Tracify Tracify `json:"tracify" yaml:"tracify"`
|
||||
// Umami provider settings
|
||||
Umami Umami `json:"umami" yaml:"umami"`
|
||||
}
|
||||
|
||||
1001
sesamy.schema.json
1001
sesamy.schema.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user