-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0af953
commit 0b83312
Showing
16 changed files
with
728 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
rm -rf completions | ||
mkdir completions | ||
|
||
for sh in bash zsh fish; do | ||
go run cmd/regen/main.go completion "$sh" >"completions/regen.$sh" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/spf13/cobra/doc" | ||
|
||
"github.com/regen-network/regen-ledger/v5/app/client/cli" | ||
) | ||
|
||
// generate documentation for all regen app commands | ||
func main() { | ||
rootCmd, _ := cli.NewRootCmd() | ||
err := doc.GenMarkdownTree(rootCmd, "commands") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
# NOTE: fork of github.com/raviqqe/gherkin2markdown with Rule support | ||
go install github.com/ryanchristo/gherkin2markdown@latest | ||
|
||
echo "Generating data feature docs..." | ||
|
||
data_dir="docs/modules/data/features" | ||
data_server_dir="$data_dir/server" | ||
data_types_dir="$data_dir/types" | ||
|
||
mkdir -p $data_server_dir | ||
mkdir -p $data_types_dir | ||
|
||
data_readme="# Features\n\n" | ||
data_readme+="## Types\n\n" | ||
|
||
for file in $(find ./x/data/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
data_readme+="- [$name](./types/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$data_types_dir/$name.md" | ||
done | ||
|
||
data_readme+="\n## Server\n\n" | ||
|
||
for file in $(find ./x/data/server -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
data_readme+="- [$name](./server/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$data_server_dir/$name.md" | ||
done | ||
|
||
echo -e "$data_readme" > "$data_dir/README.md" | ||
|
||
echo "Generating ecocredit feature docs..." | ||
|
||
eco_dir="docs/modules/ecocredit/features" | ||
eco_server_dir="$eco_dir/server" | ||
eco_types_dir="$eco_dir/types" | ||
|
||
mkdir -p $eco_server_dir | ||
mkdir -p $eco_types_dir | ||
|
||
eco_readme="# Features\n\n" | ||
eco_readme+="## Types\n\n" | ||
eco_readme+="### Base\n\n" | ||
|
||
for file in $(find ./x/ecocredit/base/types/v1/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
eco_readme+="- [$name](./types/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$eco_types_dir/$name.md" | ||
done | ||
|
||
eco_readme+="### Basket\n\n" | ||
|
||
for file in $(find ./x/ecocredit/basket/types/v1/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
eco_readme+="- [$name](./types/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$eco_types_dir/$name.md" | ||
done | ||
|
||
eco_readme+="### Marketplace\n\n" | ||
|
||
for file in $(find ./x/ecocredit/marketplace/types/v1/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
eco_readme+="- [$name](./types/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$eco_types_dir/$name.md" | ||
done | ||
|
||
eco_readme+="## Server\n\n" | ||
eco_readme+="### Base\n\n" | ||
|
||
for file in $(find ./x/ecocredit/base/keeper/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
eco_readme+="- [$name](./server/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$eco_server_dir/$name.md" | ||
done | ||
|
||
eco_readme+="### Basket\n\n" | ||
|
||
for file in $(find ./x/ecocredit/basket/keeper/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
eco_readme+="- [$name](./server/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$eco_server_dir/$name.md" | ||
done | ||
|
||
eco_readme+="### Marketplace\n\n" | ||
|
||
for file in $(find ./x/ecocredit/marketplace/keeper/features -path -prune -o -name '*.feature' | sort -t '\0' -n); do | ||
name=$(basename "${file%.*}") | ||
eco_readme+="- [$name](./server/$name.html)\n" | ||
"$GOBIN/gherkin2markdown" "$file" > "$eco_server_dir/$name.md" | ||
done | ||
|
||
echo -e "$eco_readme" > "$eco_dir/README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
SWAGGER_DIR=./app/client/docs | ||
SWAGGER_UI_DIR=${SWAGGER_DIR}/swagger-ui | ||
|
||
SDK_VERSION=$(go list -m -f '{{ .Version }}' github.com/cosmos/cosmos-sdk) | ||
IBC_VERSION=$(go list -m -f '{{ .Version }}' github.com/cosmos/ibc-go/v5) | ||
|
||
SDK_RAW_URL=https://raw.githubusercontent.com/cosmos/cosmos-sdk/${SDK_VERSION}/client/docs/swagger-ui/swagger.yaml | ||
IBC_RAW_URL=https://raw.githubusercontent.com/cosmos/ibc-go/${IBC_VERSION}/docs/client/swagger-ui/swagger.yaml | ||
|
||
SWAGGER_UI_VERSION=4.11.0 | ||
SWAGGER_UI_DOWNLOAD_URL=https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${SWAGGER_UI_VERSION}.zip | ||
SWAGGER_UI_PACKAGE_NAME=${SWAGGER_DIR}/swagger-ui-${SWAGGER_UI_VERSION} | ||
|
||
# install swagger-combine if not already installed | ||
npm list -g | grep swagger-combine > /dev/null || npm install -g swagger-combine --no-shrinkwrap | ||
|
||
# install statik if not already installed | ||
go install github.com/rakyll/statik@latest | ||
|
||
# download Cosmos SDK swagger yaml file | ||
echo "SDK version ${SDK_VERSION}" | ||
curl -o ${SWAGGER_DIR}/swagger-sdk.yaml -sfL "${SDK_RAW_URL}" | ||
|
||
# download IBC swagger yaml file | ||
echo "IBC version ${IBC_VERSION}" | ||
curl -o ${SWAGGER_DIR}/swagger-ibc.yaml -sfL "${IBC_RAW_URL}" | ||
|
||
# combine swagger yaml files using nodejs package `swagger-combine` | ||
# all the individual swagger files need to be configured in `config.json` for merging | ||
swagger-combine ${SWAGGER_DIR}/config.json -f yaml \ | ||
-o ${SWAGGER_DIR}/swagger.yaml \ | ||
--continueOnConflictingPaths true \ | ||
--includeDefinitions true | ||
|
||
# if swagger-ui does not exist locally, download swagger-ui and move dist directory to | ||
# swagger-ui directory, then remove zip file and unzipped swagger-ui directory | ||
if [ ! -d ${SWAGGER_UI_DIR} ]; then | ||
# download swagger-ui | ||
curl -o ${SWAGGER_UI_PACKAGE_NAME}.zip -sfL ${SWAGGER_UI_DOWNLOAD_URL} | ||
# unzip swagger-ui package | ||
unzip ${SWAGGER_UI_PACKAGE_NAME}.zip -d ${SWAGGER_DIR} | ||
# move swagger-ui dist directory to swagger-ui directory | ||
mv ${SWAGGER_UI_PACKAGE_NAME}/dist ${SWAGGER_UI_DIR} | ||
# remove swagger-ui zip file and unzipped swagger-ui directory | ||
rm -rf ${SWAGGER_UI_PACKAGE_NAME}.zip ${SWAGGER_UI_PACKAGE_NAME} | ||
fi | ||
|
||
# move generated swagger yaml file to swagger-ui directory | ||
cp ${SWAGGER_DIR}/swagger.yaml ${SWAGGER_DIR}/swagger-ui/ | ||
|
||
# update swagger initializer to default to swagger.yaml | ||
# Note: using -i.bak makes this compatible with both GNU and BSD/Mac | ||
sed -i.bak "s|https://petstore.swagger.io/v2/swagger.json|swagger.yaml|" ${SWAGGER_UI_DIR}/swagger-initializer.js | ||
|
||
# generate statik golang code using updated swagger-ui directory | ||
statik -src=${SWAGGER_DIR}/swagger-ui -dest=${SWAGGER_DIR} -f -m | ||
|
||
# log whether or not the swagger directory was updated | ||
if [ -n "$(git status ${SWAGGER_DIR} --porcelain)" ]; then | ||
echo "Swagger statik file updated" | ||
else | ||
echo "Swagger statik file already in sync" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
commitTitle="$(cat $1 | head -n1)" | ||
|
||
# ignore merge | ||
if echo "$commitTitle" | grep -qE "^Merge branch \'"; then | ||
exit 0 | ||
fi | ||
|
||
# check semantic commits | ||
if ! echo "$commitTitle" | grep -qE '^(?:feat|fix|docs|style|refactor|perf|test|chore)\(?(?:\w+|\s|\-|_)?\)?:\s\w+'; then | ||
echo "Your commit was successful but the commit message did not follow semantic commits." | ||
echo "Semantic commits are not required but the first commit of a new branch should be semantic." | ||
echo "See https://www.conventionalcommits.org/en/v1.0.0/ for more information about semantic commits." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
CMDS='gofmt goimports misspell' | ||
STAGED_GO_FILES=$(git diff --cached --name-only -- '*.go') | ||
LOCAL_IMPORTS='github.com/tendermint/tendermint,github.com/cosmos/cosmos-sdk,github.com/cosmos/ibc-go,github.com/regen-network/regen-ledger' | ||
|
||
# check go tools | ||
for cmd in ${CMDS}; do | ||
which "${cmd}" &>/dev/null || echo "\"${cmd}\" not found, skipping pre-commit formatting" || exit 0 | ||
done | ||
|
||
# format staged files | ||
if [[ $STAGED_GO_FILES != "" ]]; then | ||
echo "Running pre-commit formatting on staged files..." | ||
|
||
for file in $STAGED_GO_FILES; do | ||
if [[ $file =~ \.pb\.go ]] || [[ $file =~ \.pulsar.go ]] || [[ $file =~ \.cosmos_orm.go ]] || [[ $file =~ \statik.go ]]; then | ||
continue | ||
fi | ||
|
||
gofmt -w -s "$file" | ||
goimports -w -local $LOCAL_IMPORTS "$file" | ||
misspell -w "$file" | ||
git add "$file" | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
if [ -z ${1+x} ]; then | ||
echo "USAGE: | ||
./scripts/go-update-dep-all.sh <go-mod-dependency> | ||
This command updates a dependency in all of the go.mod files which import it. | ||
It should be called with a single argument which is the go module path of the dependency, | ||
with an optional version specified by @." | ||
exit | ||
fi | ||
|
||
dependency=$1 | ||
# in case the user explicitly specified a dependency version with @, we separate | ||
# the dependency module name into dependency_mod | ||
IFS='@' read -ra dependency_mod <<< "$dependency" | ||
dependency_mod=${dependency_mod[0]} | ||
|
||
for modfile in $(find . -name go.mod); do | ||
if grep $dependency_mod $modfile &> /dev/null; then | ||
echo "Updating $modfile" | ||
DIR=$(dirname $modfile) | ||
(cd $DIR; go get -u $dependency) | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
SWAGGER_DIR=./app/client/docs | ||
|
||
cd ./proto | ||
|
||
# find all proto directories | ||
proto_dirs=$(find ./regen -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) | ||
|
||
# loop through proto directories | ||
for dir in $proto_dirs; do | ||
# generate swagger files (filter query files) | ||
query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' \)) | ||
if [[ ! -z "$query_file" ]]; then | ||
buf generate --template buf.gen.swagger.yaml $query_file | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,32 @@ set -eo pipefail | |
|
||
protoc_gen_gocosmos() { | ||
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then | ||
echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder." | ||
echo -e "\tPlease run this command from somewhere inside the regen-ledger folder." | ||
return 1 | ||
fi | ||
|
||
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2>/dev/null | ||
go get github.com/cosmos/[email protected] 2>/dev/null | ||
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null | ||
} | ||
|
||
protoc_gen_gocosmos | ||
|
||
cosmos_sdk_dir=$(go list -f '{{ .Dir }}' -m github.com/cosmos/cosmos-sdk) | ||
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) | ||
echo "Generating gogo proto code" | ||
cd proto | ||
proto_dirs=$(find ./regen -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) | ||
for dir in $proto_dirs; do | ||
buf protoc \ | ||
-I "proto" \ | ||
-I "$cosmos_sdk_dir/third_party/proto" \ | ||
-I "$cosmos_sdk_dir/proto" \ | ||
--gocosmos_out=plugins=interfacetype+grpc,\ | ||
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ | ||
--grpc-gateway_out=logtostderr=true:. \ | ||
$(find "${dir}" -maxdepth 1 -name '*.proto') | ||
|
||
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do | ||
if grep go_package $file &> /dev/null ; then | ||
buf generate --template buf.gen.gogo.yaml $file | ||
fi | ||
done | ||
done | ||
|
||
cd .. | ||
|
||
# move proto files to the right places | ||
cp -r github.com/cosmic-horizon/qwoyn/* ./ | ||
cp -r github.com/regen-network/regen-ledger/* ./ | ||
rm -rf github.com | ||
|
||
go mod tidy | ||
|
||
./scripts/protocgen2.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# this script is for generating protobuf files for the new google.golang.org/protobuf API | ||
|
||
set -eo pipefail | ||
|
||
protoc_gen_install() { | ||
go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest #2>/dev/null | ||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest #2>/dev/null | ||
go install github.com/cosmos/cosmos-sdk/orm/cmd/protoc-gen-go-cosmos-orm@latest #2>/dev/null | ||
} | ||
|
||
protoc_gen_install | ||
|
||
echo "Generating API module" | ||
(cd api; find ./ -type f \( -iname \*.pulsar.go -o -iname \*.pb.go -o -iname \*.cosmos_orm.go -o -iname \*.pb.gw.go \) -delete; find . -empty -type d -delete; cd ..) | ||
(cd proto; buf generate --template buf.gen.pulsar.yaml) |
Empty file.
Oops, something went wrong.