-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# 定义目标目录, 将目录下的所有文件重命名, 文件名结尾添加 ".tpl" | ||
DIR=$(PWD)"/cmd/kitctl/internal/cmd/templates/skeleton" | ||
|
||
# 确保目标目录存在 | ||
if [ -d "$DIR" ]; then | ||
# 使用 find 命令递归查找所有文件并重命名 | ||
find "$DIR" -type f | while read -r FILE; do | ||
# 检查文件是否以 .tpl 结尾 | ||
if [[ "$FILE" != *.tpl ]]; then | ||
# 获取文件的目录路径 | ||
DIRNAME=$(dirname "$FILE") | ||
# 获取文件名 | ||
BASENAME=$(basename "$FILE") | ||
if [ $BASENAME == "docs.go" ]; then | ||
#echo "跳过:$FILE" | ||
continue # 跳过当前迭代 | ||
fi | ||
# 新文件名 | ||
NEWNAME="${BASENAME}.tpl" | ||
# 重命名文件 | ||
mv "$FILE" "$DIRNAME/$NEWNAME" | ||
else | ||
echo "文件已以 .tpl 结尾,跳过:$FILE" | ||
fi | ||
done | ||
echo "所有文件已重命名并添加 .tpl 后缀" | ||
else | ||
echo "目录不存在:$DIR" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# 设置 LC_ALL 以避免非法字节序列错误 | ||
export LC_ALL=C | ||
|
||
# 定义要替换的目录 | ||
target_dir=$(PWD)"/cmd/kitctl/internal/cmd/templates/skeleton" | ||
|
||
# 使用 find 命令递归查找所有文件,并使用 sed 进行替换 | ||
find "$target_dir" -type f -exec sed -i '' 's|github.com/yituoshiniao/gin-api-http|{{ .Mod }}|g' {} + | ||
|
||
find "$target_dir" -type f -exec sed -i '' 's|github.com/yituoshiniao/kit|gitlab.abc.net/cs-server2/kit|g' {} + | ||
|
||
# 替换应用名称 | ||
find "$target_dir" -type f -exec sed -i '' 's|gin-api-http|{{ .AppName }}|g' {} + | ||
find "$target_dir" -type f -exec sed -i '' 's|goodsCenterLogic|{{ .AppName }}|g' {} + | ||
|
||
|
||
|
||
|
||
# 将 abcdefg/cad 替换成 {{ .Mod }} | ||
#find "$target_dir" -type f -exec sed -i '' 's|abcdefg/cad|{{ .Mod }}|g' {} + | ||
|
||
echo "替换完成" |