Implement MVC

This commit is contained in:
Sung Won Cho 2021-01-03 17:51:57 +11:00
commit cd5d094c25
146 changed files with 13596 additions and 2328 deletions

View file

@ -3,17 +3,9 @@
# dev.sh builds and starts development environment
set -eux -o pipefail
# clean up background processes
function cleanup {
kill "$devServerPID"
}
trap cleanup EXIT
dir=$(dirname "${BASH_SOURCE[0]}")
basePath="$dir/../.."
appPath="$basePath/web"
serverPath="$basePath/pkg/server"
serverPort=3000
# load env
set -a
@ -21,20 +13,22 @@ dotenvPath="$serverPath/.env.dev"
source "$dotenvPath"
set +a
# run webpack-dev-server for js in the background
(
BUNDLE_BASE_URL=http://localhost:8080 \
ASSET_BASE_URL=http://localhost:3000/static \
ROOT_URL=http://localhost:$serverPort \
COMPILED_PATH="$appPath"/compiled \
PUBLIC_PATH="$appPath"/public \
COMPILED_PATH="$basePath/web/compiled" \
STANDALONE=true \
VERSION="$VERSION" \
WEBPACK_HOST="0.0.0.0" \
"$dir/webpack-dev.sh"
) &
devServerPID=$!
# copy assets
mkdir -p "$basePath/pkg/server/static"
cp "$basePath"/pkg/server/assets/static/* "$basePath/pkg/server/static"
# run asset pipeline in the background
(cd "$basePath/pkg/server/assets/" && "$basePath/pkg/server/assets/styles/build.sh" true ) &
(cd "$basePath/pkg/server/assets/" && "$basePath/pkg/server/assets/js/build.sh") &
# run server
(cd "$basePath/pkg/watcher" && go run main.go --task="go run main.go start -port 3000" --context="$serverPath" "$serverPath")
moduleName="github.com/dnote/dnote"
ldflags="-X '$moduleName/pkg/server/buildinfo.CSSFiles=main.css' -X '$moduleName/pkg/server/buildinfo.JSFiles=main.js' -X '$moduleName/pkg/server/buildinfo.Version=dev'"
task="go run -ldflags \"$ldflags\" main.go start -port 3000"
(
cd "$basePath/pkg/watcher" && \
go run main.go \
--task="$task" \
--context="$serverPath" \
"$serverPath"
)