Files
log/run.zsh
syui 5ce03098bd
Some checks are pending
Deploy ailog / build-and-deploy (push) Waiting to run
fix stream env
2025-06-12 19:59:19 +09:00

65 lines
1.1 KiB
Bash
Executable File

#!/bin/zsh
function _env() {
d=${0:a:h}
ailog=$d/target/release/ailog
oauth=$d/oauth
myblog=$d/my-blog
port=4173
source $oauth/.env.production
case $OSTYPE in
darwin*)
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
;;
esac
}
function _server() {
_env
lsof -ti:$port | xargs kill -9 2>/dev/null || true
cd $d/my-blog
cargo build --release
$ailog build
$ailog serve --port $port
}
function _server_public() {
_env
cloudflared tunnel --config $d/cloudflared-config.yml run
}
function _oauth_build() {
_env
cd $oauth
nvm use 21
npm i
npm run build
rm -rf $myblog/static/assets
cp -rf dist/* $myblog/static/
cp $oauth/dist/index.html $myblog/templates/oauth-assets.html
#npm run preview
}
function _server_comment() {
_env
cargo build --release
AILOG_DEBUG_ALL=1 $ailog stream start
}
case "${1:-serve}" in
tunnel|c)
_server_public
;;
oauth|o)
_oauth_build
;;
comment|co)
_server_comment
;;
serve|s|*)
_server
;;
esac