From 4c026755c40054d51dcf943486dfe996ef2639ae Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 18 May 2025 16:47:32 +0800 Subject: [PATCH] feat: Update versioning and commit information in Makefile and version command - Added CUI commit information to the Makefile for artifact generation. - Enhanced version command output to include Yao and CUI commit details with improved formatting. - Updated constant names in share/const.go for clarity on versioning. - Fixed references to CUI commit in process and app files to align with new naming conventions. --- Makefile | 12 +++++------- cmd/version.go | 47 +++++++++++++++++++++++++++++++--------------- engine/process.go | 2 +- share/const.go | 6 +++--- widgets/app/app.go | 2 +- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index c0b57699..e8d13434 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/) GOFILES := $(shell find . -name "*.go") VERSION := $(shell grep 'const VERSION =' share/const.go |awk '{print $$4}' |sed 's/\"//g') COMMIT := $(shell git log | head -n 1 | awk '{print substr($$2, 0, 12)}') +CUI_COMMIT_RELEASE := $(shell cd .tmp/cui/v1.0 && git log | head -n 1 | awk '{print substr($$2, 0, 12)}') +CUI_COMMIT_ARTIFACTS := $(shell cd ../cui-v1.0 && git log | head -n 1 | awk '{print $$2}') NOW := $(shell date +"%FT%T%z") OS := $(shell uname) @@ -175,6 +177,7 @@ artifacts-linux: clean # Replace PRVERSION sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}-${NOW}\"/g" share/const.go + sed -ie "s/const PRCUI = \"DEV\"/const PRCUI = \"${CUI_COMMIT_ARTIFACTS}-${NOW}\"/g" share/const.go # Making artifacts mkdir -p dist @@ -209,13 +212,6 @@ artifacts-macos: clean cd ../yao-init && rm -rf LICENSE # cd ../yao-init && rm -rf README.md -# Yao Builder -# Remove Yao Builder - DUI PageBuilder component will provide online design for pure HTML pages or SUI pages in the future. -# mkdir -p .tmp/data/builder -# curl -o .tmp/yao-builder-latest.tar.gz https://release-sv.yaoapps.com/archives/yao-builder-latest.tar.gz -# tar -zxvf .tmp/yao-builder-latest.tar.gz -C .tmp/data/builder -# rm -rf .tmp/yao-builder-latest.tar.gz - # Packing # ** CUI will be renamed to CUI in the feature. and move to the new repository. ** # ** new repository: https://github.com/YaoApp/cui.git ** @@ -230,6 +226,7 @@ artifacts-macos: clean # Replace PRVERSION sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}-${NOW}\"/g" share/const.go + sed -ie "s/const PRCUI = \"DEV\"/const PRCUI = \"${CUI_COMMIT_ARTIFACTS}-${NOW}\"/g" share/const.go # Making artifacts mkdir -p dist @@ -316,6 +313,7 @@ release: clean # Replace PRVERSION sed -ie "s/const PRVERSION = \"DEV\"/const PRVERSION = \"${COMMIT}-${NOW}\"/g" share/const.go + sed -ie "s/const PRCUI = \"DEV\"/const PRCUI = \"${CUI_COMMIT_RELEASE}-${NOW}\"/g" share/const.go # Making artifacts mkdir -p dist diff --git a/cmd/version.go b/cmd/version.go index 9b37f145..67e104d1 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -2,18 +2,22 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" - "github.com/yaoapp/yao/share" "runtime" "strings" + + "github.com/fatih/color" + "github.com/spf13/cobra" + "github.com/yaoapp/yao/share" ) var printAllVersion bool -var versionTemplate = `Version: %s -Go version: %s -Git commit: %s -Built: %s -OS/Arch: %s/%s +var versionTemplate = `Version: %s +Go version: %s +Yao commit: %s +Cui version: %s +Cui commit: %s +Built: %s +OS/Arch: %s/%s ` var versionCmd = &cobra.Command{ Use: "version", @@ -23,16 +27,29 @@ var versionCmd = &cobra.Command{ if printAllVersion { commit := strings.Split(share.PRVERSION, "-")[0] buildTime := strings.TrimPrefix(share.PRVERSION, commit+"-") - fmt.Printf(versionTemplate, - share.VERSION, - runtime.Version(), - commit, buildTime, - runtime.GOOS, - runtime.GOARCH) + cuiCommit := strings.Split(share.PRCUI, "-")[0] + + fmt.Printf("%s", color.WhiteString("Yao version: ")) + fmt.Printf("%s\n", color.GreenString(share.VERSION)) + + fmt.Printf("%s", color.WhiteString("Yao commit: ")) + fmt.Printf("%s\n", color.YellowString(commit)) + + fmt.Printf("%s", color.WhiteString("Cui commit: ")) + fmt.Printf("%s\n", color.YellowString(cuiCommit)) + + fmt.Printf("%s", color.WhiteString("Built: ")) + fmt.Printf("%s\n", color.BlueString(buildTime)) + + fmt.Printf("%s", color.WhiteString("OS/Arch: ")) + fmt.Printf("%s\n", color.MagentaString("%s/%s", runtime.GOOS, runtime.GOARCH)) + + fmt.Printf("%s", color.WhiteString("Go version: ")) + fmt.Printf("%s\n", color.CyanString(runtime.Version())) return } - // Do Stuff Here - fmt.Println(share.VERSION) + fmt.Printf("%s", color.WhiteString("Yao version: ")) + fmt.Printf("%s\n", color.GreenString(share.VERSION)) }, } diff --git a/engine/process.go b/engine/process.go index 5a93ce0e..4e2beb66 100644 --- a/engine/process.go +++ b/engine/process.go @@ -39,7 +39,7 @@ func processPing(process *process.Process) interface{} { func processInspect(process *process.Process) interface{} { return map[string]interface{}{ "VERSION": fmt.Sprintf("%s %s", share.VERSION, share.PRVERSION), - "CUI": fmt.Sprintf("%s %s", share.CUI, share.PRECUI), + "CUI": fmt.Sprintf("%s %s", share.CUI, share.PRCUI), "BUILDNAME": share.BUILDNAME, "CONFIG": config.Conf, } diff --git a/share/const.go b/share/const.go index 03201cbe..4d0ebfb2 100644 --- a/share/const.go +++ b/share/const.go @@ -3,14 +3,14 @@ package share // VERSION Yao App Engine Version const VERSION = "0.10.5" -// PRVERSION Yao App Engine PreRelease Version +// PRVERSION Yao App Engine PR Commit const PRVERSION = "DEV" // CUI Version const CUI = "0.10.5" -// PRECUI PreRelease Version -const PRECUI = "DEV" +// PRCUI CUI PR Commit +const PRCUI = "DEV" // BUILDIN If true, the application will be built into a single artifact const BUILDIN = false diff --git a/widgets/app/app.go b/widgets/app/app.go index 090fb711..a7741dc7 100644 --- a/widgets/app/app.go +++ b/widgets/app/app.go @@ -588,7 +588,7 @@ func processXgen(process *process.Process) interface{} { }, "cui": map[string]interface{}{ "version": share.CUI, - "prversion": share.PRECUI, + "prversion": share.PRCUI, }, "theme": Setting.Theme, "lang": Setting.Lang,