From 23cd699db01c8200a59f1ba57ce170a25b4c77d9 Mon Sep 17 00:00:00 2001 From: David Janowski Date: Tue, 20 Feb 2024 10:45:07 +0100 Subject: [PATCH] feat: added base directory's --- .gitignore | 6 +++--- .gitmodules | 4 ++-- api/gRPC/.gitkeep | 0 cmd/.gitkeep | 0 config/.gitkeep | 0 deployment/.gitkeep | 1 + internal/.gitkeep | 0 pkg/.gitkeep | 0 scripts/README.md | 9 +++++++++ scripts/generate_grpc_files.ps1 | 28 ++++++++++++++++++++++++++++ scripts/generate_grpc_files.sh | 19 +++++++++++++++++++ 11 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 api/gRPC/.gitkeep create mode 100644 cmd/.gitkeep create mode 100644 config/.gitkeep create mode 100644 deployment/.gitkeep create mode 100644 internal/.gitkeep create mode 100644 pkg/.gitkeep create mode 100644 scripts/README.md create mode 100644 scripts/generate_grpc_files.ps1 create mode 100644 scripts/generate_grpc_files.sh 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"