mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-08 23:52:26 +08:00
refactor: eiblog
This commit is contained in:
3
scripts/README.md
Normal file
3
scripts/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Scripts to perform various build, install, analysis, etc operations.
|
||||
|
||||
These scripts keep the root level Makefile small and simple.
|
||||
51
scripts/new_app.sh
Executable file
51
scripts/new_app.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
# ensuer new app?
|
||||
read -p "Are you sure new app? [y/n] " ensure
|
||||
if [ "$ensure" != "y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
os="$(uname -s)"
|
||||
old=$(echo "github.com/deepzz0/appdemo" | sed "s/\//\\\\\//g")
|
||||
|
||||
tmp="$(pwd)"
|
||||
new=$(echo "${tmp/$GOPATH\/src\//}" | sed "s/\//\\\\\//g")
|
||||
appname="${tmp##*/}"
|
||||
|
||||
_sed_i() {
|
||||
option="$1"
|
||||
file="$2"
|
||||
if [ "$os" = "Darwin" ]; then
|
||||
sed -i "" "$option" "$file"
|
||||
else
|
||||
sed -i "$option" "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
printf 'Project [\33[1;32m%b\33[0m], initializing...\n' "$appname"
|
||||
|
||||
# rename appname
|
||||
_sed_i "1s/demo/$appname/" "conf/app.yml"
|
||||
echo "Clean conf/app.yml"
|
||||
|
||||
# rename module
|
||||
_sed_i "1s/$old/$new/" "go.mod"
|
||||
echo "Clean go.mod"
|
||||
|
||||
# rename package ref
|
||||
find . -name "*.go" | while read fname; do
|
||||
_sed_i "s/$old/$new/g" "$fname"
|
||||
done
|
||||
echo "Clean *.go"
|
||||
|
||||
# clean git
|
||||
rm -rf .git
|
||||
echo "Clean git repo"
|
||||
|
||||
# init empty repo
|
||||
git init
|
||||
|
||||
printf '\33[1;32m%b\33[0m' "Successful initialization."
|
||||
3
scripts/run_app.sh
Executable file
3
scripts/run_app.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
go run cmd/$1/main.go
|
||||
24
scripts/run_build.sh
Executable file
24
scripts/run_build.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
_registry="$1"
|
||||
_tag="$2"
|
||||
|
||||
if [ -z "$_registry" ] || [ -z "$_tag" ]; then
|
||||
echo "Please specify image repository and tag."
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# prepare dir ./bin
|
||||
mkdir -p ./bin
|
||||
|
||||
# build demo app
|
||||
for file in pkg/core/*; do
|
||||
app="$(basename $file)";
|
||||
GOOS=linux GOARCH=amd64 go build -o bin/backend "./cmd/$app"
|
||||
docker build -f "build/package/$app.Dockerfile" -t "$_registry/$app:$_tag" .
|
||||
done
|
||||
|
||||
# clean dir ./bin
|
||||
rm -rf ./bin
|
||||
9
scripts/swag_init.sh
Executable file
9
scripts/swag_init.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
for file in pkg/core/*; do
|
||||
if test -d $file; then
|
||||
cd $file && swag init -g api.go;
|
||||
cd -;
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user