diff --git a/.gitignore b/.gitignore index f7b74d3..8e75de2 100644 --- a/.gitignore +++ b/.gitignore @@ -189,6 +189,6 @@ $RECYCLE.BIN/ .idea/* /.run/* - - -*.env \ No newline at end of file +*.env +api/gRPC/* +!**/.gitkeep \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 604dc88..88731c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "thrid_party/grpc-proto"] - path = thrid_party/grpc-proto +[submodule "third_party/grpc-proto"] + path = third_party/grpc-proto url = https://git.dragse.it/anthrove/grpc-proto.git branch = release/v1.0.0 \ No newline at end of file diff --git a/api/gRPC/.gitkeep b/api/gRPC/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/cmd/.gitkeep b/cmd/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/deployment/.gitkeep b/deployment/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/deployment/.gitkeep @@ -0,0 +1 @@ + diff --git a/internal/.gitkeep b/internal/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pkg/.gitkeep b/pkg/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..eabcfcf --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,9 @@ +# Generate the gRPC files + +To generate the gRPC files you need to do the following: + +1. Download the Git submodules (if you didn't clone this repo with ``git clone --recurse-submodules``) +```bash +git submodule init +git submodule update +``` \ No newline at end of file diff --git a/scripts/generate_grpc_files.ps1 b/scripts/generate_grpc_files.ps1 new file mode 100644 index 0000000..9c57b2a --- /dev/null +++ b/scripts/generate_grpc_files.ps1 @@ -0,0 +1,28 @@ +New-Item -Path "api" -Name "gRPC" -ItemType Directory -Force + +$plugName = "" + +protoc ` + --proto_path=third_party/grpc-proto ` + --go_out=api/gRPC ` + --go_opt=paths=source_relative ` + --go-grpc_out=api/gRPC ` + --go-grpc_opt=paths=source_relative ` + third_party/grpc-proto/*.proto ` + + +function Replace-Text { + param ( + [string]$Path, + [string]$OldText, + [string]$NewText + ) + + Get-ChildItem -Path $Path -Recurse -File | ForEach-Object { + $content = Get-Content $_.FullName + $content = $content -replace $OldText, $NewText + Set-Content -Path $_.FullName -Value $content + } +} + +Replace-Text -Path "./api/gRPC" -OldText "git.dragse.it/anthrove/plug-[REPLACE_ME]/api/gRPC" -NewText "git.dragse.it/anthrove/plug-$plugName/api/gRPC" diff --git a/scripts/generate_grpc_files.sh b/scripts/generate_grpc_files.sh new file mode 100644 index 0000000..091cd52 --- /dev/null +++ b/scripts/generate_grpc_files.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +mkdir -p "api/gRPC" + +plugName = "" + +protoc \ + --proto_path=third_party/grpc-proto \ + --go_out=api/gRPC \ + --go_opt=paths=source_relative \ + --go-grpc_out=api/gRPC \ + --go-grpc_opt=paths=source_relative \ + third_party/grpc-proto/*.proto + +dir_path="./api/gRPC" +old_text="git.dragse.it/anthrove/plug-[REPLACE_ME]/api/gRPC" +new_text="git.dragse.it/anthrove/plug-$plugName/api/gRPC"" + +grep -rlZ "$old_text" "$dir_path" | xargs -0 sed -i "s#$old_text#$new_text#g"