From 0ede803fb39dfdcf180b7078d07cb5ab2fd22997 Mon Sep 17 00:00:00 2001 From: timqiu <9145422+cocoonwind@user.noreply.gitee.com> Date: Sat, 22 Mar 2025 00:44:53 +0800 Subject: [PATCH] Update for frontend update --- devbox/cli/devbox | 118 +++++++++++++++++++++++++++++++--------------- 1 file changed, 81 insertions(+), 37 deletions(-) diff --git a/devbox/cli/devbox b/devbox/cli/devbox index b0b754e..95ac05a 100644 --- a/devbox/cli/devbox +++ b/devbox/cli/devbox @@ -49,6 +49,7 @@ exit_with_message() { exit $code } + detect_os() { if [[ "$OSTYPE" == "darwin"* ]]; then echo "darwin" @@ -634,17 +635,6 @@ get_port() { done } -# Build the local image -build_local_image() { - local dockerfile_path="$1" - log_info "[BUILD] Building local image..." - docker buildx build \ - --platform linux/amd64 \ - --build-arg BUILDARCH="x86-64-v3" \ - -t $devbox_full_image \ - -f "$dockerfile_path" . -} - ############################################### # Initialize the development environment @@ -794,17 +784,36 @@ if true ; then # 3️⃣ Clean up old dependencies if [ -f "pnpm-lock.yaml" ]; then - mv pnpm-lock.yaml /tmp/pnpm-lock.yaml.bak + cp pnpm-lock.yaml /tmp/pnpm-lock.yaml.bak fi - rm -rf node_modules pnpm-lock.yaml + rm -rf node_modules # 4️⃣ Install dependencies (ensuring lockfile updates) - pnpm install --no-frozen-lockfile + pnpm install --no-frozen-lockfile \\ + --shamefully-hoist \\ + --link-workspace-packages false \\ + --store-dir /home/devbox/.pnpm-store + + # 4️⃣ Build the frontend pnpm run build + + # 5️⃣ Check git status + echo + echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Checking git status..." + echo + + git config --global --add safe.directory /home/devbox/freeleaps + git status -s + + echo + echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Git status check completed." + echo + + echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') Backend and frontend environment initialization completed." fi @@ -1155,6 +1164,12 @@ docker exec -i "$DEVBOX_NAME" bash < "\$baseline_frontend" + + # save baseline to /home/devbox/tmp/baseline_frontend + mkdir -p /home/devbox/tmp + cp "\$baseline_frontend" /home/devbox/tmp/baseline_frontend.bak + + echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Recorded baseline before compilation: \$baseline_frontend" # Check if the frontend service is already running according to the package.json and pnpm-lock.yaml files timestamps @@ -1163,12 +1178,18 @@ docker exec -i "$DEVBOX_NAME" bash < /home/devbox/logs/frontend.logs 2>&1 & + # Check git status + echo + echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Checking git status..." + echo + git status -s + echo + echo "[FRONTEND] \$(date '+%Y-%m-%d %H:%M:%S') Git status check completed." + echo + # Check the health of the frontend service: poll to detect HTTP status MAX_ATTEMPTS=30 ATTEMPT=0 @@ -1289,6 +1322,21 @@ docker exec -i "$DEVBOX_NAME" bash < /dev/null + git config --global --add safe.directory /home/devbox/freeleaps + git reset --hard HEAD + popd > /dev/null + echo "[INIT] \$(date '+%Y-%m-%d %H:%M:%S') FreeLeaps repository reset completed." +EOF +} + # :command.command_functions # :command.function devbox_init_command() { @@ -1942,28 +1990,23 @@ IS_START_FRONTEND=true compile_backend_service compile_frontend_service -docker exec -i "$DEVBOX_NAME" bash <