mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
This pull request primarily removes submodule management targets from the `Makefile` and makes minor updates to the project documentation in both English and Chinese. The most important changes are grouped below. Makefile cleanup: * Removed the `subup` and `subsync` targets from the `Makefile`, eliminating commands related to updating and committing submodules. Documentation updates: * Updated the logo alt text in both `README.MD` and `README.zh_CN.MD` from "goframe gf logo" to "goframe logo" for clarity. [[1]](diffhunk://#diff-01e6d9ffed056a02cae8d8a0ec5d476a64d017bf85c0d5a94bb23ca21f33f5aaL4-R4) [[2]](diffhunk://#diff-c93759cb9a9500f20e551c741eb167fc72825fd638d36121357feb8253ce6ac1L4-R4) * Revised a description in `README.zh_CN.MD` to clarify the framework's purpose, changing “一个强大的框架” to “一款强大的框架”. * Simplified the license description in `README.zh_CN.MD` to state "100%开源和免费".
114 lines
4.1 KiB
Bash
Executable File
114 lines
4.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
|
||
# Function to run sed in-place with OS-specific options
|
||
sed_replace() {
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||
# macOS - requires empty string after -i
|
||
sed -i '' "$@"
|
||
else
|
||
# Linux/Windows Git Bash
|
||
sed -i "$@"
|
||
fi
|
||
}
|
||
|
||
if [ $# -ne 2 ]; then
|
||
echo "Parameter exception, please execute in the format of $0 [directory] [version number]"
|
||
echo "PS:$0 ./ v2.4.0"
|
||
exit 1
|
||
fi
|
||
|
||
if [ ! -d "$1" ]; then
|
||
echo "Error: Directory does not exist"
|
||
exit 1
|
||
fi
|
||
|
||
if [[ "$2" != v* ]]; then
|
||
echo "Error: Version number must start with v"
|
||
exit 1
|
||
fi
|
||
|
||
workdir=.
|
||
newVersion=$2
|
||
echo "Prepare to replace the GoFrame library version numbers in all go.mod files in the ${workdir} directory with ${newVersion}"
|
||
|
||
# check find command support or not
|
||
output=$(find "${workdir}" -name go.mod 2>&1)
|
||
if [[ $? -ne 0 ]]; then
|
||
echo "Error: please use bash or zsh to run!"
|
||
exit 1
|
||
fi
|
||
|
||
if [[ true ]]; then
|
||
# Use sed to replace the version number in version.go
|
||
sed_replace 's/VERSION = ".*"/VERSION = "'${newVersion}'"/' version.go
|
||
|
||
# Use sed to replace the version number in README.MD
|
||
sed_replace 's/version=[^"]*/version='${newVersion}'/' README.MD
|
||
sed_replace 's/version=[^"]*/version='${newVersion}'/' README.zh_CN.MD
|
||
fi
|
||
|
||
if [ -f "go.work" ]; then
|
||
mv go.work go.work.version.bak
|
||
echo "Back up the go.work file to avoid affecting the upgrade"
|
||
fi
|
||
|
||
for file in `find ${workdir} -name go.mod`; do
|
||
goModPath=$(dirname $file)
|
||
echo ""
|
||
echo "processing dir: $goModPath"
|
||
|
||
if [[ $goModPath =~ "/testdata/" ]]; then
|
||
echo "ignore testdata path $goModPath"
|
||
continue 1
|
||
fi
|
||
|
||
if [[ $goModPath =~ "/examples/" ]]; then
|
||
echo "ignore examples path $goModPath"
|
||
continue 1
|
||
fi
|
||
|
||
cd $goModPath
|
||
|
||
# Add replace directive for local development.
|
||
if [ $goModPath = "./cmd/gf" ]; then
|
||
mv go.work go.work.version.bak
|
||
go mod edit -replace github.com/gogf/gf/v2=../../
|
||
go mod edit -replace github.com/gogf/gf/contrib/drivers/clickhouse/v2=../../contrib/drivers/clickhouse
|
||
go mod edit -replace github.com/gogf/gf/contrib/drivers/mssql/v2=../../contrib/drivers/mssql
|
||
go mod edit -replace github.com/gogf/gf/contrib/drivers/mysql/v2=../../contrib/drivers/mysql
|
||
go mod edit -replace github.com/gogf/gf/contrib/drivers/oracle/v2=../../contrib/drivers/oracle
|
||
go mod edit -replace github.com/gogf/gf/contrib/drivers/pgsql/v2=../../contrib/drivers/pgsql
|
||
go mod edit -replace github.com/gogf/gf/contrib/drivers/sqlite/v2=../../contrib/drivers/sqlite
|
||
fi
|
||
# Remove indirect dependencies
|
||
sed_replace '/\/\/ indirect/d' go.mod
|
||
go mod tidy
|
||
# Remove toolchain line if exists
|
||
sed_replace '/^toolchain/d' go.mod
|
||
|
||
# Upgrading only GoFrame related libraries, sometimes even if a version number is specified,
|
||
# it may not be possible to successfully upgrade. Please confirm before submitting the code
|
||
go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf"
|
||
go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v
|
||
# Remove indirect dependencies
|
||
sed_replace '/\/\/ indirect/d' go.mod
|
||
go mod tidy
|
||
# Remove toolchain line if exists
|
||
sed_replace '/^toolchain/d' go.mod
|
||
if [ $goModPath = "./cmd/gf" ]; then
|
||
go mod edit -dropreplace github.com/gogf/gf/v2
|
||
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/clickhouse/v2
|
||
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/mssql/v2
|
||
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/mysql/v2
|
||
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/oracle/v2
|
||
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/pgsql/v2
|
||
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/sqlite/v2
|
||
mv go.work.version.bak go.work
|
||
fi
|
||
cd -
|
||
done
|
||
|
||
if [ -f "go.work.version.bak" ]; then
|
||
mv go.work.version.bak go.work
|
||
echo "Restore the go.work file"
|
||
fi |