go-duck-cli 1.1.13 β 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -1
- package/generators/kratos.js +20 -0
- package/package.json +1 -1
- package/templates/docs/pages/grpc.hbs +45 -0
package/README.md
CHANGED
|
@@ -74,6 +74,14 @@ GO-DUCK has officially reached the **375% Achievement Status**, evolving from a
|
|
|
74
74
|
* **SaaS Quota Engine**: Redis-backed API bandwidth tracking with dynamic, hierarchical limits (User vs. Role mapping).
|
|
75
75
|
* **Resilience Layer**: Sony/Gobreaker Integration + Zero-Trust Distributed Redis Rate Limiter.
|
|
76
76
|
|
|
77
|
+
### πΊοΈ System Topology & Identity Registry
|
|
78
|
+
|
|
79
|
+
To prevent ID enumeration attacks and completely hide internal database names and structure, GO-DUCK implements a zero-trust **Triple-Identity Registry** (Role β DB β Opaque UUID):
|
|
80
|
+
|
|
81
|
+
<p align="center">
|
|
82
|
+
<img src="https://goduck.theheavenscode.com/triple_identity_registry.png" alt="Triple-Identity Registry Topology" width="800"/>
|
|
83
|
+
</p>
|
|
84
|
+
|
|
77
85
|
## πΎ Global Installation
|
|
78
86
|
|
|
79
87
|
To get started with GO-DUCK CLI, install it globally via npm:
|
|
@@ -99,9 +107,42 @@ Follow these steps to create and run a new microservice with GO-DUCK:
|
|
|
99
107
|
# 1. Create a new microservice
|
|
100
108
|
go-duck create -o ./my-app -c config.yaml
|
|
101
109
|
|
|
102
|
-
# 2. Enter the application directory
|
|
110
|
+
# 2. Enter the application directory
|
|
103
111
|
cd my-app
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### ποΈ Compiling Protobuf & gRPC Contracts
|
|
115
|
+
|
|
116
|
+
Before running the microservice, compile the protobuf contract files using the scaffolded scripts:
|
|
117
|
+
|
|
118
|
+
#### Prerequisites
|
|
119
|
+
1. Ensure the `protoc` compiler is installed and added to your system's `PATH`.
|
|
120
|
+
2. Install the necessary Go compiler plugins:
|
|
121
|
+
```cmd
|
|
122
|
+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
|
123
|
+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Compilation
|
|
127
|
+
Execute the script corresponding to your operating system in the root of the generated microservice directory:
|
|
128
|
+
|
|
129
|
+
* **Windows CMD / PowerShell**:
|
|
130
|
+
```cmd
|
|
131
|
+
.\generate.bat
|
|
132
|
+
```
|
|
133
|
+
* **Linux / macOS / Git Bash / WSL**:
|
|
134
|
+
```bash
|
|
135
|
+
chmod +x generate.sh
|
|
136
|
+
./generate.sh
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Once compiled, launch the dependencies and start the application:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# 3. Spin up dependent services
|
|
104
143
|
docker-compose up -d
|
|
144
|
+
|
|
145
|
+
# 4. Run the Go application
|
|
105
146
|
go run main.go
|
|
106
147
|
```
|
|
107
148
|
|
package/generators/kratos.js
CHANGED
|
@@ -213,9 +213,29 @@ find api -name "*.proto" -exec protoc --proto_path=. \\
|
|
|
213
213
|
{} +
|
|
214
214
|
|
|
215
215
|
echo "β
Protos compiled successfully!"
|
|
216
|
+
`;
|
|
217
|
+
const generateBat = `@echo off
|
|
218
|
+
echo π¦ Syncing Protobuf Dependencies...
|
|
219
|
+
if not exist "third_party\\google\\api" mkdir "third_party\\google\\api"
|
|
220
|
+
curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > third_party\\google\\api\\annotations.proto
|
|
221
|
+
curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > third_party\\google\\api\\http.proto
|
|
222
|
+
|
|
223
|
+
echo ποΈ Compiling API Layer...
|
|
224
|
+
where protoc >nul 2>nul
|
|
225
|
+
if %errorlevel% neq 0 (
|
|
226
|
+
echo β Error: 'protoc' not found. Please install protobuf and add it to your PATH.
|
|
227
|
+
exit /b 1
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
for /f "tokens=*" %%f in ('dir /b /s api\\*.proto') do (
|
|
231
|
+
protoc --proto_path=. --proto_path=./api --proto_path=./third_party --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. "%%f"
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
echo β
Protos compiled successfully!
|
|
216
235
|
`;
|
|
217
236
|
await fs.writeFile(path.join(projectRootDir, 'generate.sh'), generateSh);
|
|
218
237
|
await fs.chmod(path.join(projectRootDir, 'generate.sh'), 0o755);
|
|
238
|
+
await fs.writeFile(path.join(projectRootDir, 'generate.bat'), generateBat);
|
|
219
239
|
|
|
220
240
|
console.log(chalk.green('β
Kratos gRPC code generated successfully!'));
|
|
221
241
|
};
|
package/package.json
CHANGED
|
@@ -45,6 +45,51 @@ service {{capitalize (defaultStr (lookup entities "0.name") "Entity")}}Service {
|
|
|
45
45
|
</div>
|
|
46
46
|
</section>
|
|
47
47
|
|
|
48
|
+
<!-- Compiling Protobuf Contracts -->
|
|
49
|
+
<section class="mb-20">
|
|
50
|
+
<h2 class="text-3xl font-black text-slate-900 mb-6 tracking-tight italic underline decoration-blue-200 underline-offset-8">Compiling Protobuf & gRPC Contracts</h2>
|
|
51
|
+
<p class="text-lg text-slate-600 mb-8 leading-relaxed">
|
|
52
|
+
GO-DUCK scaffolds script files in the root of the generated project to manage the compilation of <code>.proto</code> contracts natively on all operating systems.
|
|
53
|
+
</p>
|
|
54
|
+
|
|
55
|
+
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm mb-8">
|
|
56
|
+
<h3 class="text-xl font-bold text-slate-800 mb-4 flex items-center">
|
|
57
|
+
π οΈ Scaffolded Compiler Scripts
|
|
58
|
+
</h3>
|
|
59
|
+
<p class="text-slate-600 mb-4">The generator scaffolds both <code>generate.sh</code> and <code>generate.bat</code> files in the project root. At compilation time, they perform the following tasks:</p>
|
|
60
|
+
<ul class="list-disc pl-6 space-y-2 text-slate-600 mb-6">
|
|
61
|
+
<li>Create the <code>third_party/google/api</code> dependencies directory.</li>
|
|
62
|
+
<li>Synchronize necessary Google API annotation contracts (<code>annotations.proto</code> and <code>http.proto</code>) using native command line transfers.</li>
|
|
63
|
+
<li>Recursively find and compile all <code>.proto</code> files inside <code>api/</code> into Go source files using the <code>protoc</code> compiler.</li>
|
|
64
|
+
</ul>
|
|
65
|
+
|
|
66
|
+
<h3 class="text-xl font-bold text-slate-800 mb-4 flex items-center">
|
|
67
|
+
π How to Compile
|
|
68
|
+
</h3>
|
|
69
|
+
<p class="text-slate-600 mb-4">To compile the contract schemas into Go source structures, execute the following commands in the root of your generated application:</p>
|
|
70
|
+
|
|
71
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
72
|
+
<div class="p-6 bg-slate-50 rounded-2xl border border-slate-200">
|
|
73
|
+
<span class="text-xs font-black text-blue-600 uppercase tracking-widest block mb-2">Windows (CMD / PowerShell)</span>
|
|
74
|
+
<pre class="bg-slate-900 text-slate-100 p-4 rounded-xl text-xs font-mono">.\generate.bat</pre>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="p-6 bg-slate-50 rounded-2xl border border-slate-200">
|
|
77
|
+
<span class="text-xs font-black text-emerald-600 uppercase tracking-widest block mb-2">Unix / Linux / macOS</span>
|
|
78
|
+
<pre class="bg-slate-900 text-slate-100 p-4 rounded-xl text-xs font-mono">chmod +x generate.sh<br>./generate.sh</pre>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div class="mt-8 p-6 bg-blue-50 rounded-2xl border border-blue-100">
|
|
83
|
+
<h4 class="font-bold text-blue-900 mb-2">π Compilation Prerequisites</h4>
|
|
84
|
+
<p class="text-blue-800 text-sm leading-relaxed mb-4">
|
|
85
|
+
Ensure you have the <code>protoc</code> binary installed and added to your system's <code>PATH</code>.
|
|
86
|
+
</p>
|
|
87
|
+
<p class="text-blue-800 text-sm leading-relaxed mb-2">Also ensure the necessary Go compiler plugins are installed on your environment:</p>
|
|
88
|
+
<pre class="bg-slate-900 text-slate-100 p-4 rounded-xl text-xs font-mono">go install google.golang.org/protobuf/cmd/protoc-gen-go@latest<br>go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest</pre>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</section>
|
|
92
|
+
|
|
48
93
|
<!-- Silo-Aware Repository Wrapper -->
|
|
49
94
|
<section class="mb-20">
|
|
50
95
|
<div class="bg-gradient-to-r from-blue-950 to-blue-900 border border-blue-800/50 rounded-[2.5rem] p-16 text-white text-center shadow-2xl relative overflow-hidden group">
|