rapidkit 0.25.6 → 0.26.0
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 +10 -5
- package/dist/chunk-U7XJZHU6.js +160 -0
- package/dist/{create-27NVMJAR.js → create-YIUV6RUX.js} +20 -15
- package/dist/demo-kit-HMJZ3A3M.js +141 -0
- package/dist/doctor-JEBQTQQE.js +38 -0
- package/dist/{gofiber-standard-NQHMZTFK.js → gofiber-standard-JDPREQCP.js} +30 -205
- package/dist/{gogin-standard-2G2C3VQL.js → gogin-standard-DCERHHVB.js} +31 -228
- package/dist/index.js +188 -169
- package/dist/package.json +4 -2
- package/dist/springboot-standard-AGTOOTNT.js +697 -0
- package/dist/{workspace-VXNLNKCM.js → workspace-VN3VF62I.js} +87 -69
- package/package.json +4 -2
- package/dist/demo-kit-63CFMCPD.js +0 -141
- package/dist/doctor-P57TTWEP.js +0 -38
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b as b$1}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import
|
|
1
|
+
import {c,b as b$2,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b as b$1}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import d from'path';import o from'chalk';import _ from'ora';import {execa}from'execa';function T(e){return `package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|
|
@@ -65,56 +65,17 @@ func main() {
|
|
|
65
65
|
}
|
|
66
66
|
slog.Info("server stopped")
|
|
67
67
|
}
|
|
68
|
-
`}function
|
|
68
|
+
`}function O(e){return `module ${e.module_path}
|
|
69
69
|
|
|
70
70
|
go ${e.go_version}
|
|
71
71
|
|
|
72
72
|
require (
|
|
73
73
|
github.com/gin-gonic/gin v1.10.0
|
|
74
|
+
github.com/swaggo/files v1.0.1
|
|
74
75
|
github.com/swaggo/gin-swagger v1.6.0
|
|
75
76
|
github.com/swaggo/swag v1.16.3
|
|
76
77
|
)
|
|
77
|
-
|
|
78
|
-
require (
|
|
79
|
-
github.com/KyleBanks/depth v1.2.1 // indirect
|
|
80
|
-
github.com/bytedance/sonic v1.11.6 // indirect
|
|
81
|
-
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
|
82
|
-
github.com/cloudwego/base64x v0.1.4 // indirect
|
|
83
|
-
github.com/cloudwego/iasm v0.2.0 // indirect
|
|
84
|
-
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
|
85
|
-
github.com/ghodss/yaml v1.0.0 // indirect
|
|
86
|
-
github.com/gin-contrib/sse v0.1.0 // indirect
|
|
87
|
-
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
|
88
|
-
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
|
89
|
-
github.com/go-openapi/spec v0.21.0 // indirect
|
|
90
|
-
github.com/go-openapi/swag v0.23.0 // indirect
|
|
91
|
-
github.com/go-playground/locales v0.14.1 // indirect
|
|
92
|
-
github.com/go-playground/universal-translator v0.18.1 // indirect
|
|
93
|
-
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
|
94
|
-
github.com/goccy/go-json v0.10.2 // indirect
|
|
95
|
-
github.com/josharian/intern v1.0.0 // indirect
|
|
96
|
-
github.com/json-iterator/go v1.1.12 // indirect
|
|
97
|
-
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
|
98
|
-
github.com/leodido/go-urn v1.4.0 // indirect
|
|
99
|
-
github.com/mailru/easyjson v0.7.7 // indirect
|
|
100
|
-
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
101
|
-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
|
102
|
-
github.com/modern-go/reflect2 v1.0.2 // indirect
|
|
103
|
-
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
|
104
|
-
github.com/swaggo/files v1.0.1 // indirect
|
|
105
|
-
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
|
106
|
-
github.com/ugorji/go/codec v1.2.12 // indirect
|
|
107
|
-
golang.org/x/arch v0.8.0 // indirect
|
|
108
|
-
golang.org/x/crypto v0.23.0 // indirect
|
|
109
|
-
golang.org/x/net v0.25.0 // indirect
|
|
110
|
-
golang.org/x/sys v0.20.0 // indirect
|
|
111
|
-
golang.org/x/text v0.15.0 // indirect
|
|
112
|
-
golang.org/x/tools v0.21.0 // indirect
|
|
113
|
-
google.golang.org/protobuf v1.34.1 // indirect
|
|
114
|
-
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
115
|
-
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
116
|
-
)
|
|
117
|
-
`}function S(e){return `package config
|
|
78
|
+
`}function N(e){return `package config
|
|
118
79
|
|
|
119
80
|
import (
|
|
120
81
|
"log/slog"
|
|
@@ -221,7 +182,7 @@ func NewRouter(cfg *config.Config) *gin.Engine {
|
|
|
221
182
|
|
|
222
183
|
return r
|
|
223
184
|
}
|
|
224
|
-
`}function
|
|
185
|
+
`}function G(){return `package handlers
|
|
225
186
|
|
|
226
187
|
import (
|
|
227
188
|
"net/http"
|
|
@@ -260,7 +221,7 @@ func Readiness(c *gin.Context) {
|
|
|
260
221
|
"time": time.Now().UTC().Format(time.RFC3339),
|
|
261
222
|
})
|
|
262
223
|
}
|
|
263
|
-
`}function
|
|
224
|
+
`}function q(e){return `package handlers_test
|
|
264
225
|
|
|
265
226
|
import (
|
|
266
227
|
"encoding/json"
|
|
@@ -305,7 +266,7 @@ func TestReadiness(t *testing.T) {
|
|
|
305
266
|
t.Fatalf("expected 200, got %d: %s", w.Code, w.Body.String())
|
|
306
267
|
}
|
|
307
268
|
}
|
|
308
|
-
`}function
|
|
269
|
+
`}function E(){return `# \u2500\u2500 Build stage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
309
270
|
FROM golang:1.24-alpine AS builder
|
|
310
271
|
|
|
311
272
|
# Build-time version injection
|
|
@@ -334,7 +295,7 @@ EXPOSE 8080
|
|
|
334
295
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
|
|
335
296
|
CMD wget -qO- http://localhost:8080/api/v1/health/live || exit 1
|
|
336
297
|
ENTRYPOINT ["/server"]
|
|
337
|
-
`}function
|
|
298
|
+
`}function L(e){return `version: "3.9"
|
|
338
299
|
|
|
339
300
|
services:
|
|
340
301
|
api:
|
|
@@ -350,61 +311,7 @@ services:
|
|
|
350
311
|
CORS_ALLOW_ORIGINS: "*"
|
|
351
312
|
RATE_LIMIT_RPS: "100"
|
|
352
313
|
restart: unless-stopped
|
|
353
|
-
`}function
|
|
354
|
-
|
|
355
|
-
# Build-time metadata
|
|
356
|
-
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
|
357
|
-
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
|
|
358
|
-
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
359
|
-
LDFLAGS = -ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
|
|
360
|
-
# Go tool binaries are installed to GOPATH/bin; include it so \`air\` and \`swag\` are found.
|
|
361
|
-
GOBIN ?= $(shell go env GOPATH)/bin
|
|
362
|
-
|
|
363
|
-
# Hot reload \u2014 installs air on first use
|
|
364
|
-
dev:
|
|
365
|
-
@test -x "$(GOBIN)/air" || go install github.com/air-verse/air@latest
|
|
366
|
-
GIN_MODE=debug $(GOBIN)/air
|
|
367
|
-
|
|
368
|
-
run:
|
|
369
|
-
GIN_MODE=debug go run $(LDFLAGS) ./cmd/server
|
|
370
|
-
|
|
371
|
-
build:
|
|
372
|
-
go build $(LDFLAGS) -o bin/${e.project_name} ./cmd/server
|
|
373
|
-
|
|
374
|
-
test:
|
|
375
|
-
GIN_MODE=test go test ./... -v -race
|
|
376
|
-
|
|
377
|
-
cover:
|
|
378
|
-
GIN_MODE=test go test ./... -race -coverprofile=coverage.out
|
|
379
|
-
go tool cover -html=coverage.out -o coverage.html
|
|
380
|
-
@echo "Coverage report: coverage.html"
|
|
381
|
-
|
|
382
|
-
# Generate Swagger docs \u2014 installs swag on first use
|
|
383
|
-
docs:
|
|
384
|
-
@test -x "$(GOBIN)/swag" || go install github.com/swaggo/swag/cmd/swag@latest
|
|
385
|
-
$(GOBIN)/swag init -g main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency
|
|
386
|
-
|
|
387
|
-
lint:
|
|
388
|
-
@command -v golangci-lint >/dev/null 2>&1 || (echo "golangci-lint not found. Install: https://golangci-lint.run/usage/install/" && exit 1)
|
|
389
|
-
golangci-lint run ./...
|
|
390
|
-
|
|
391
|
-
fmt:
|
|
392
|
-
gofmt -w .
|
|
393
|
-
|
|
394
|
-
tidy:
|
|
395
|
-
go mod tidy
|
|
396
|
-
|
|
397
|
-
docker-up:
|
|
398
|
-
go mod tidy
|
|
399
|
-
docker compose up --build \\
|
|
400
|
-
--build-arg VERSION=$(VERSION) \\
|
|
401
|
-
--build-arg COMMIT=$(COMMIT) \\
|
|
402
|
-
--build-arg DATE=$(DATE) \\
|
|
403
|
-
-d
|
|
404
|
-
|
|
405
|
-
docker-down:
|
|
406
|
-
docker compose down
|
|
407
|
-
`}function G(e){return `# Application
|
|
314
|
+
`}function C(e){return d$1({projectName:e.project_name,devCommand:"GIN_MODE=debug $(GOBIN)/air",runCommand:"GIN_MODE=debug go run $(LDFLAGS) ./cmd/server",testCommand:"GIN_MODE=test go test ./... -v -race",includeLintAndFmt:true})}function y(e){return `# Application
|
|
408
315
|
PORT=${e.port}
|
|
409
316
|
APP_ENV=development
|
|
410
317
|
GIN_MODE=debug
|
|
@@ -415,7 +322,7 @@ CORS_ALLOW_ORIGINS=*
|
|
|
415
322
|
|
|
416
323
|
# Rate limiting \u2014 max requests per IP per second
|
|
417
324
|
RATE_LIMIT_RPS=100
|
|
418
|
-
`}function
|
|
325
|
+
`}function I(){return `# Binaries
|
|
419
326
|
bin/
|
|
420
327
|
*.exe
|
|
421
328
|
*.exe~
|
|
@@ -455,7 +362,7 @@ docs/docs.go
|
|
|
455
362
|
# OS
|
|
456
363
|
.DS_Store
|
|
457
364
|
Thumbs.db
|
|
458
|
-
`}function
|
|
365
|
+
`}function x(e){return `name: CI
|
|
459
366
|
|
|
460
367
|
on:
|
|
461
368
|
push:
|
|
@@ -509,7 +416,7 @@ jobs:
|
|
|
509
416
|
uses: golangci/golangci-lint-action@v6
|
|
510
417
|
with:
|
|
511
418
|
version: latest
|
|
512
|
-
`}function
|
|
419
|
+
`}function M(e){return `# ${b$2(e.project_name)}
|
|
513
420
|
|
|
514
421
|
> ${e.description}
|
|
515
422
|
|
|
@@ -625,7 +532,7 @@ ${e.project_name}/
|
|
|
625
532
|
## License
|
|
626
533
|
|
|
627
534
|
${e.app_version} \xB7 ${e.author}
|
|
628
|
-
`}function
|
|
535
|
+
`}function k(){return `package middleware
|
|
629
536
|
|
|
630
537
|
import (
|
|
631
538
|
"crypto/rand"
|
|
@@ -677,7 +584,7 @@ func newID() string {
|
|
|
677
584
|
}
|
|
678
585
|
return hex.EncodeToString(b)
|
|
679
586
|
}
|
|
680
|
-
`}function
|
|
587
|
+
`}function A(e){return `package middleware_test
|
|
681
588
|
|
|
682
589
|
import (
|
|
683
590
|
"net/http"
|
|
@@ -726,7 +633,7 @@ func TestRequestID_IsReused(t *testing.T) {
|
|
|
726
633
|
t.Fatalf("expected X-Request-ID to be reused, got %q", id)
|
|
727
634
|
}
|
|
728
635
|
}
|
|
729
|
-
`}function
|
|
636
|
+
`}function P(){return `// Package apierr provides a consistent JSON error envelope for all API responses.
|
|
730
637
|
//
|
|
731
638
|
// Every error response looks like:
|
|
732
639
|
//
|
|
@@ -789,7 +696,7 @@ func InternalError(c *gin.Context, _ error) {
|
|
|
789
696
|
func TooManyRequests(c *gin.Context) {
|
|
790
697
|
reply(c, http.StatusTooManyRequests, "rate limit exceeded", "TOO_MANY_REQUESTS")
|
|
791
698
|
}
|
|
792
|
-
`}function
|
|
699
|
+
`}function D(e){return `package apierr_test
|
|
793
700
|
|
|
794
701
|
import (
|
|
795
702
|
"encoding/json"
|
|
@@ -915,11 +822,11 @@ func TestTooManyRequests(t *testing.T) {
|
|
|
915
822
|
t.Fatalf("expected TOO_MANY_REQUESTS, got %q", body.Code)
|
|
916
823
|
}
|
|
917
824
|
}
|
|
918
|
-
`}function
|
|
825
|
+
`}function H(e){return `// Package docs provides the swaggo-generated OpenAPI specification.
|
|
919
826
|
//
|
|
920
827
|
// Run \`make docs\` to regenerate after changing handler annotations.
|
|
921
828
|
//
|
|
922
|
-
// @title ${
|
|
829
|
+
// @title ${b$2(e.project_name)} API
|
|
923
830
|
// @version ${e.app_version}
|
|
924
831
|
// @description ${e.description}
|
|
925
832
|
// @host localhost:${e.port}
|
|
@@ -929,7 +836,7 @@ func TestTooManyRequests(t *testing.T) {
|
|
|
929
836
|
// @contact.name ${e.author}
|
|
930
837
|
// @license.name MIT
|
|
931
838
|
package docs
|
|
932
|
-
`}function
|
|
839
|
+
`}function F(e){return `package handlers
|
|
933
840
|
|
|
934
841
|
import (
|
|
935
842
|
"net/http"
|
|
@@ -971,7 +878,7 @@ func EchoParams(c *gin.Context) {
|
|
|
971
878
|
RequestID: c.GetString("X-Request-ID"),
|
|
972
879
|
})
|
|
973
880
|
}
|
|
974
|
-
`}function
|
|
881
|
+
`}function $(e){return `package handlers_test
|
|
975
882
|
|
|
976
883
|
import (
|
|
977
884
|
"encoding/json"
|
|
@@ -1036,7 +943,7 @@ func TestEchoParams_EmptyName(t *testing.T) {
|
|
|
1036
943
|
t.Fatalf("expected code=BAD_REQUEST, got %v", body["code"])
|
|
1037
944
|
}
|
|
1038
945
|
}
|
|
1039
|
-
`}function
|
|
946
|
+
`}function j(e){return `package config_test
|
|
1040
947
|
|
|
1041
948
|
import (
|
|
1042
949
|
"log/slog"
|
|
@@ -1112,7 +1019,7 @@ func TestLoad_Defaults(t *testing.T) {
|
|
|
1112
1019
|
t.Errorf("expected default GinMode=debug, got %q", cfg.GinMode)
|
|
1113
1020
|
}
|
|
1114
1021
|
}
|
|
1115
|
-
`}function
|
|
1022
|
+
`}function U(){return `package middleware
|
|
1116
1023
|
|
|
1117
1024
|
import (
|
|
1118
1025
|
"net/http"
|
|
@@ -1160,7 +1067,7 @@ func CORS() gin.HandlerFunc {
|
|
|
1160
1067
|
c.Next()
|
|
1161
1068
|
}
|
|
1162
1069
|
}
|
|
1163
|
-
`}function
|
|
1070
|
+
`}function B(e){return `package middleware_test
|
|
1164
1071
|
|
|
1165
1072
|
import (
|
|
1166
1073
|
"net/http"
|
|
@@ -1246,7 +1153,7 @@ func TestCORS_Default_Origin(t *testing.T) {
|
|
|
1246
1153
|
t.Fatal("expected CORS header when CORS_ALLOW_ORIGINS defaults to *")
|
|
1247
1154
|
}
|
|
1248
1155
|
}
|
|
1249
|
-
`}function
|
|
1156
|
+
`}function V(e){return `package server_test
|
|
1250
1157
|
|
|
1251
1158
|
import (
|
|
1252
1159
|
"encoding/json"
|
|
@@ -1356,7 +1263,7 @@ func TestServer_ReleaseMode(t *testing.T) {
|
|
|
1356
1263
|
t.Fatalf("expected 200 in release mode, got %d", w.Code)
|
|
1357
1264
|
}
|
|
1358
1265
|
}
|
|
1359
|
-
`}function
|
|
1266
|
+
`}function W(e){return `package middleware
|
|
1360
1267
|
|
|
1361
1268
|
import (
|
|
1362
1269
|
"os"
|
|
@@ -1407,7 +1314,7 @@ func RateLimit() gin.HandlerFunc {
|
|
|
1407
1314
|
c.Next()
|
|
1408
1315
|
}
|
|
1409
1316
|
}
|
|
1410
|
-
`}function
|
|
1317
|
+
`}function J(e){return `package middleware_test
|
|
1411
1318
|
|
|
1412
1319
|
import (
|
|
1413
1320
|
"net/http"
|
|
@@ -1476,7 +1383,7 @@ func TestRateLimit_InvalidRPS(t *testing.T) {
|
|
|
1476
1383
|
t.Fatalf("expected 200 with invalid RPS env, got %d", w.Code)
|
|
1477
1384
|
}
|
|
1478
1385
|
}
|
|
1479
|
-
`}function
|
|
1386
|
+
`}function K(e){return `# Air \u2014 live reload for Go projects
|
|
1480
1387
|
# https://github.com/air-verse/air
|
|
1481
1388
|
root = "."
|
|
1482
1389
|
tmp_dir = "tmp"
|
|
@@ -1501,7 +1408,7 @@ tmp_dir = "tmp"
|
|
|
1501
1408
|
|
|
1502
1409
|
[log]
|
|
1503
1410
|
time = false
|
|
1504
|
-
`}function
|
|
1411
|
+
`}function X(e){return `run:
|
|
1505
1412
|
timeout: 5m
|
|
1506
1413
|
|
|
1507
1414
|
linters:
|
|
@@ -1547,110 +1454,6 @@ issues:
|
|
|
1547
1454
|
linters:
|
|
1548
1455
|
- errcheck
|
|
1549
1456
|
- wrapcheck
|
|
1550
|
-
`}function
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
1555
|
-
CMD="\${1:-}"
|
|
1556
|
-
shift 2>/dev/null || true
|
|
1557
|
-
|
|
1558
|
-
case "$CMD" in
|
|
1559
|
-
init)
|
|
1560
|
-
cd "$SCRIPT_DIR"
|
|
1561
|
-
echo "\u{1F439} Initializing Go/Gin project\u2026"
|
|
1562
|
-
GOBIN="$(go env GOPATH)/bin"
|
|
1563
|
-
echo " \u2192 installing air (hot reload)\u2026"
|
|
1564
|
-
go install github.com/air-verse/air@latest 2>/dev/null && echo " \u2713 air" || echo " \u26A0 air install failed (run: go install github.com/air-verse/air@latest)"
|
|
1565
|
-
echo " \u2192 installing swag (swagger)\u2026"
|
|
1566
|
-
go install github.com/swaggo/swag/cmd/swag@latest 2>/dev/null && echo " \u2713 swag" || echo " \u26A0 swag install failed (run: go install github.com/swaggo/swag/cmd/swag@latest)"
|
|
1567
|
-
if [ ! -f ".env" ] && [ -f ".env.example" ]; then
|
|
1568
|
-
cp .env.example .env && echo " \u2713 .env created from .env.example"
|
|
1569
|
-
fi
|
|
1570
|
-
go mod tidy && echo " \u2713 go mod tidy"
|
|
1571
|
-
echo " \u2192 generating swagger docs (first build)\u2026"
|
|
1572
|
-
"$(go env GOPATH)/bin/swag" init -g main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency 2>/dev/null && echo " \u2713 swagger docs generated" || echo " \u26A0 swagger docs skipped (run: rapidkit docs)"
|
|
1573
|
-
echo "\u2705 Ready \u2014 run: rapidkit dev"
|
|
1574
|
-
;;
|
|
1575
|
-
dev)
|
|
1576
|
-
cd "$SCRIPT_DIR"
|
|
1577
|
-
echo "\u{1F4D6} Syncing swagger docs\u2026"
|
|
1578
|
-
"$(go env GOPATH)/bin/swag" init -g main.go -d cmd/server,internal/handlers,internal/apierr -o docs --parseDependency 2>/dev/null || true
|
|
1579
|
-
if [ -f "$SCRIPT_DIR/Makefile" ]; then
|
|
1580
|
-
exec make -C "$SCRIPT_DIR" dev "$@"
|
|
1581
|
-
else
|
|
1582
|
-
cd "$SCRIPT_DIR" && GIN_MODE=debug exec go run ./cmd/server "$@"
|
|
1583
|
-
fi
|
|
1584
|
-
;;
|
|
1585
|
-
start)
|
|
1586
|
-
BIN="$SCRIPT_DIR/bin/${e.project_name}"
|
|
1587
|
-
if [ ! -f "$BIN" ]; then
|
|
1588
|
-
make -C "$SCRIPT_DIR" build
|
|
1589
|
-
fi
|
|
1590
|
-
exec "$BIN" "$@"
|
|
1591
|
-
;;
|
|
1592
|
-
build)
|
|
1593
|
-
exec make -C "$SCRIPT_DIR" build "$@"
|
|
1594
|
-
;;
|
|
1595
|
-
test)
|
|
1596
|
-
exec make -C "$SCRIPT_DIR" test "$@"
|
|
1597
|
-
;;
|
|
1598
|
-
lint)
|
|
1599
|
-
exec make -C "$SCRIPT_DIR" lint "$@"
|
|
1600
|
-
;;
|
|
1601
|
-
format|fmt)
|
|
1602
|
-
exec make -C "$SCRIPT_DIR" fmt "$@"
|
|
1603
|
-
;;
|
|
1604
|
-
docs)
|
|
1605
|
-
exec make -C "$SCRIPT_DIR" docs "$@"
|
|
1606
|
-
;;
|
|
1607
|
-
help|--help|-h)
|
|
1608
|
-
echo "RapidKit \u2014 Go/Gin project: ${e.project_name}"
|
|
1609
|
-
echo ""
|
|
1610
|
-
echo "Usage: rapidkit <command>"
|
|
1611
|
-
echo ""
|
|
1612
|
-
echo " init Install tools + create .env (air, swag, go mod tidy)"
|
|
1613
|
-
echo " dev Hot reload dev server (make dev \u2014 requires air)"
|
|
1614
|
-
echo " start Run compiled binary (make build + bin)"
|
|
1615
|
-
echo " build Build binary (make build)"
|
|
1616
|
-
echo " docs Generate Swagger docs (make docs \u2014 requires swag)"
|
|
1617
|
-
echo " test Run tests (make test)"
|
|
1618
|
-
echo " lint Run linter (make lint)"
|
|
1619
|
-
echo " format Format code (make fmt)"
|
|
1620
|
-
;;
|
|
1621
|
-
*)
|
|
1622
|
-
if [ -n "$CMD" ]; then
|
|
1623
|
-
echo "rapidkit: unknown command: $CMD" >&2
|
|
1624
|
-
fi
|
|
1625
|
-
echo "Available: init, dev, start, build, docs, test, lint, format" >&2
|
|
1626
|
-
exit 1
|
|
1627
|
-
;;
|
|
1628
|
-
esac
|
|
1629
|
-
`}function X(e){return `@echo off
|
|
1630
|
-
rem RapidKit Go/Gin project launcher \u2014 Windows
|
|
1631
|
-
set CMD=%1
|
|
1632
|
-
if "%CMD%"=="" goto usage
|
|
1633
|
-
shift
|
|
1634
|
-
|
|
1635
|
-
if "%CMD%"=="init" (
|
|
1636
|
-
echo Initializing Go/Gin project...
|
|
1637
|
-
go install github.com/air-verse/air@latest
|
|
1638
|
-
go install github.com/swaggo/swag/cmd/swag@latest
|
|
1639
|
-
if not exist .env if exist .env.example copy .env.example .env
|
|
1640
|
-
go mod tidy
|
|
1641
|
-
exit /b %ERRORLEVEL%
|
|
1642
|
-
)
|
|
1643
|
-
if "%CMD%"=="dev" ( make dev %* & exit /b %ERRORLEVEL% )
|
|
1644
|
-
if "%CMD%"=="build" ( make build %* & exit /b %ERRORLEVEL% )
|
|
1645
|
-
if "%CMD%"=="test" ( make test %* & exit /b %ERRORLEVEL% )
|
|
1646
|
-
if "%CMD%"=="lint" ( make lint %* & exit /b %ERRORLEVEL% )
|
|
1647
|
-
if "%CMD%"=="format" ( make fmt %* & exit /b %ERRORLEVEL% )
|
|
1648
|
-
if "%CMD%"=="docs" ( make docs %* & exit /b %ERRORLEVEL% )
|
|
1649
|
-
if "%CMD%"=="start" ( bin\\${e.project_name}.exe %* & exit /b %ERRORLEVEL% )
|
|
1650
|
-
|
|
1651
|
-
:usage
|
|
1652
|
-
echo Available: init, dev, start, build, docs, test, lint, format
|
|
1653
|
-
exit /b 1
|
|
1654
|
-
`}async function ne(e,o){let r={project_name:o.project_name,module_path:o.module_path||o.project_name,author:o.author||"RapidKit User",description:o.description||`Go/Gin REST API \u2014 ${o.project_name}`,go_version:o.go_version||"1.24",app_version:o.app_version||"0.1.0",port:o.port||"8080",skipGit:o.skipGit??false},g=b$1();try{await execa("go",["version"],{timeout:3e3});}catch{console.log(n.yellow("\n\u26A0 Go not found in PATH \u2014 project will be scaffolded, but `go mod tidy` requires Go 1.21+")),console.log(n.gray(` Install: https://go.dev/dl/
|
|
1655
|
-
`));}let i=f(`Generating Go/Gin project: ${r.project_name}\u2026`).start();try{let t=(m,h)=>w(s.join(e,m),h),u=s.join(e,"rapidkit"),p=s.join(e,"rapidkit.cmd");await Promise.all([t("cmd/server/main.go",v(r)),t("go.mod",R(r)),t("internal/config/config.go",S(r)),t("internal/server/server.go",b(r)),t("internal/middleware/requestid.go",I()),t("internal/middleware/requestid_test.go",L(r)),t("internal/apierr/apierr.go",x()),t("internal/apierr/apierr_test.go",k(r)),t("internal/handlers/health.go",T()),t("internal/handlers/health_test.go",_(r)),t("internal/handlers/example.go",D(r)),t("internal/handlers/example_test.go",P(r)),t("internal/config/config_test.go",A(r)),t("internal/middleware/cors.go",H()),t("internal/middleware/cors_test.go",$(r)),t("internal/middleware/ratelimit.go",j(r)),t("internal/middleware/ratelimit_test.go",U(r)),t("internal/server/server_test.go",F(r)),t("docs/doc.go",M(r)),t(".air.toml",B(r)),t("Dockerfile",O()),t("docker-compose.yml",N(r)),t("Makefile",E(r)),t(".golangci.yml",V(r.module_path)),t(".env.example",G(r)),t(".gitignore",q()),t(".github/workflows/ci.yml",C(r)),t("README.md",y(r)),t(".rapidkit/project.json",J(r,g)),t(".rapidkit/context.json",W()),t("rapidkit",K(r)),t("rapidkit.cmd",X(r))]),await promises.chmod(u,493),await promises.chmod(p,493),i.succeed(n.green(`Project created at ${e}`));try{i.start("Fetching Go dependencies\u2026"),await execa("go",["mod","tidy"],{cwd:e,timeout:12e4}),i.succeed(n.gray("\u2713 go mod tidy completed"));}catch{i.warn(n.yellow("\u26A0 go mod tidy failed \u2014 run manually: go mod tidy"));}if(!r.skipGit)try{await execa("git",["init"],{cwd:e}),await execa("git",["add","-A"],{cwd:e}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit gogin.standard)"],{cwd:e}),console.log(n.gray("\u2713 git repository initialized"));}catch{console.log(n.gray("\u26A0 git init skipped (git not found or error)"));}console.log(""),console.log(n.bold("\u2705 Go/Gin project ready!")),console.log(""),console.log(n.cyan("Next steps:")),console.log(n.white(` cd ${r.project_name}`)),console.log(n.white(" make run # start dev server")),console.log(n.white(" make test # run tests")),console.log(""),console.log(n.gray("Server will listen on port "+r.port)),console.log(n.gray(" http://localhost:"+r.port+"/api/v1/health/live")),console.log(n.gray(" http://localhost:"+r.port+"/api/v1/health/ready")),console.log(""),console.log(n.yellow("\u2139 RapidKit modules are not available for Go projects (module system uses Python/pip).")),console.log("");}catch(t){throw i.fail(n.red("Failed to generate Go/Gin project")),t}}
|
|
1656
|
-
export{ne as generateGoGinKit};
|
|
1457
|
+
`}function Q(){return JSON.stringify({engine:"npm",runtime:"go"},null,2)}function z(e,n){return JSON.stringify({kit_name:"gogin.standard",runtime:"go",module_support:false,project_name:e.project_name,module_path:e.module_path,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:n,created_at:new Date().toISOString()},null,2)}function Y(e$1){return e({runtimeLabel:"Go/Gin",projectName:e$1.project_name,fallbackDevCommand:'cd "$SCRIPT_DIR" && GIN_MODE=debug exec go run ./cmd/server "$@"'})}function Z(e){return f({runtimeLabel:"Go/Gin",projectName:e.project_name})}async function ce(e,n){let r={project_name:n.project_name,module_path:n.module_path||n.project_name,author:n.author||"RapidKit User",description:n.description||`Go/Gin REST API \u2014 ${n.project_name}`,go_version:n.go_version||a,app_version:n.app_version||"0.1.0",port:n.port||"8080",skipGit:n.skipGit??false},f=b$1();try{await execa("go",["version"],{timeout:3e3});}catch{console.log(o.yellow("\n\u26A0 Go not found in PATH \u2014 project will be scaffolded, but `go mod tidy` requires Go 1.21+")),console.log(o.gray(` Install: https://go.dev/dl/
|
|
1458
|
+
`));}let i=_(`Generating Go/Gin project: ${r.project_name}\u2026`).start();try{let t=(v,S)=>c(d.join(e,v),S),w=d.join(e,"rapidkit"),R=d.join(e,"rapidkit.cmd");await Promise.all([t("cmd/server/main.go",T(r)),t("go.mod",O(r)),t("internal/config/config.go",N(r)),t("internal/server/server.go",b(r)),t("internal/middleware/requestid.go",k()),t("internal/middleware/requestid_test.go",A(r)),t("internal/apierr/apierr.go",P()),t("internal/apierr/apierr_test.go",D(r)),t("internal/handlers/health.go",G()),t("internal/handlers/health_test.go",q(r)),t("internal/handlers/example.go",F(r)),t("internal/handlers/example_test.go",$(r)),t("internal/config/config_test.go",j(r)),t("internal/middleware/cors.go",U()),t("internal/middleware/cors_test.go",B(r)),t("internal/middleware/ratelimit.go",W(r)),t("internal/middleware/ratelimit_test.go",J(r)),t("internal/server/server_test.go",V(r)),t("docs/doc.go",H(r)),t(".air.toml",K(r)),t("Dockerfile",E()),t("docker-compose.yml",L(r)),t("Makefile",C(r)),t(".golangci.yml",X(r.module_path)),t(".env.example",y(r)),t(".gitignore",I()),t(".github/workflows/ci.yml",x(r)),t("README.md",M(r)),t(".rapidkit/project.json",z(r,f)),t(".rapidkit/context.json",Q()),t("rapidkit",Y(r)),t("rapidkit.cmd",Z(r))]),await promises.chmod(w,493),await promises.chmod(R,493),i.succeed(o.green(`Project created at ${e}`));try{i.start("Fetching Go dependencies\u2026"),await execa("go",["mod","tidy"],{cwd:e,timeout:12e4}),i.succeed(o.gray("\u2713 go mod tidy completed"));}catch{i.warn(o.yellow("\u26A0 go mod tidy failed \u2014 run manually: go mod tidy"));}if(!r.skipGit)try{await execa("git",["init"],{cwd:e}),await execa("git",["add","-A"],{cwd:e}),await execa("git",["commit","-m","chore: initial scaffold (rapidkit gogin.standard)"],{cwd:e}),console.log(o.gray("\u2713 git repository initialized"));}catch{console.log(o.gray("\u26A0 git init skipped (git not found or error)"));}console.log(""),console.log(o.bold("\u2705 Go/Gin project ready!")),console.log(""),console.log(o.cyan("Next steps:")),console.log(o.white(` cd ${r.project_name}`)),console.log(o.white(" make run # start dev server")),console.log(o.white(" make test # run tests")),console.log(""),console.log(o.gray("Server will listen on port "+r.port)),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/live")),console.log(o.gray(" http://localhost:"+r.port+"/api/v1/health/ready")),console.log(""),console.log(o.yellow("\u2139 RapidKit modules are not available for Go projects (module system uses Python/pip).")),console.log("");}catch(t){throw i.fail(o.red("Failed to generate Go/Gin project")),t}}
|
|
1459
|
+
export{ce as generateGoGinKit};
|