mirror of
https://github.com/veops/oneterm.git
synced 2025-09-26 19:31:14 +08:00
feat(backend): add global version configuration
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
|
||||
"github.com/veops/oneterm/internal/acl"
|
||||
"github.com/veops/oneterm/internal/model"
|
||||
"github.com/veops/oneterm/internal/version"
|
||||
"github.com/veops/oneterm/pkg/config"
|
||||
"github.com/veops/oneterm/pkg/logger"
|
||||
)
|
||||
@@ -84,16 +85,16 @@ func banner() string {
|
||||
██║ ██║██║╚██╗██║██╔══╝ ██║ ██╔══╝ ██╔══██╗██║╚██╔╝██║
|
||||
╚██████╔╝██║ ╚████║███████╗ ██║ ███████╗██║ ██║██║ ╚═╝ ██║
|
||||
╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝`
|
||||
|
||||
|
||||
lines := strings.Split(bannerText, "\n")
|
||||
var result strings.Builder
|
||||
|
||||
|
||||
for i, line := range lines {
|
||||
if line == "" {
|
||||
result.WriteString("\n")
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
var style lipgloss.Style
|
||||
switch {
|
||||
case i <= 2:
|
||||
@@ -106,22 +107,22 @@ func banner() string {
|
||||
result.WriteString(style.Render(line))
|
||||
result.WriteString("\n")
|
||||
}
|
||||
|
||||
|
||||
tagline := lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#2f54eb")).
|
||||
Bold(true).
|
||||
PaddingLeft(15).
|
||||
Render("✨ Enterprise Bastion Host Solution")
|
||||
|
||||
version := versionStyle.
|
||||
|
||||
versionText := versionStyle.
|
||||
PaddingLeft(25).
|
||||
Render("v2.0.0")
|
||||
|
||||
Render(version.Version)
|
||||
|
||||
result.WriteString("\n")
|
||||
result.WriteString(tagline)
|
||||
result.WriteString(" ")
|
||||
result.WriteString(version)
|
||||
result.WriteString(versionText)
|
||||
result.WriteString("\n")
|
||||
|
||||
|
||||
return result.String()
|
||||
}
|
||||
|
28
backend/internal/version/version.go
Normal file
28
backend/internal/version/version.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package version
|
||||
|
||||
// Version information for OneTerm
|
||||
// Update these values before each release
|
||||
const (
|
||||
// Version is the current version of OneTerm
|
||||
Version = "v25.8.1"
|
||||
|
||||
// BuildDate can be set at compile time using ldflags
|
||||
// go build -ldflags "-X github.com/veops/oneterm/internal/version.BuildDate=$(date +%Y%m%d)"
|
||||
BuildDate = ""
|
||||
|
||||
// GitCommit can be set at compile time using ldflags
|
||||
// go build -ldflags "-X github.com/veops/oneterm/internal/version.GitCommit=$(git rev-parse --short HEAD)"
|
||||
GitCommit = ""
|
||||
)
|
||||
|
||||
// GetVersion returns the full version string
|
||||
func GetVersion() string {
|
||||
v := Version
|
||||
if GitCommit != "" {
|
||||
v += "-" + GitCommit
|
||||
}
|
||||
if BuildDate != "" {
|
||||
v += " (" + BuildDate + ")"
|
||||
}
|
||||
return v
|
||||
}
|
Reference in New Issue
Block a user