From 0381f6a0bec8c36ed6e4b7061c8151d400c61129 Mon Sep 17 00:00:00 2001 From: fanmuchen Date: Wed, 7 May 2025 14:17:54 +0800 Subject: [PATCH] Initial commit 4. --- AI_RULES.md | 25 ++++++++++++------------- frontend/.gitignore | 41 ----------------------------------------- frontend/README.md | 36 ------------------------------------ sh/dev.sh | 12 +++++++++++- sh/prod.sh | 4 +++- 5 files changed, 26 insertions(+), 92 deletions(-) delete mode 100644 frontend/.gitignore delete mode 100644 frontend/README.md diff --git a/AI_RULES.md b/AI_RULES.md index edc2af2..18f6961 100644 --- a/AI_RULES.md +++ b/AI_RULES.md @@ -6,32 +6,31 @@ This is to kick start a web project with nextjs as frontend and go server as bac ``` starter/ -├-- .env -├-- sh/ -│ └── dev.sh +├── .env +├── sh/ # Shell scripts for development and deployment automation +│ ├── dev.sh +│ └── prod.sh ├── frontend/ │ ├── public/ │ ├── src/ -│ │ ├── app/ -│ │ └── components/ +│ │ └── app/ +│ │ ├── layout.tsx +│ │ ├── page.tsx +│ │ ├── favicon.ico +│ │ └── globals.css +│ ├── Dockerfile │ ├── package.json │ └── ... └── backend/ ├── internal/ - │ ├── handlers/ - │ ├── middleware/ - │ ├── models/ - │ └── routes/ - ├── go.mod - ├── go.sum + │ └── ... ├── main.go - └── Makefile + └── ... ``` ## Configuration All environmental variables should be managed in a centralized `.env` in the root dir of the repo, as we'll source them when running deploying scripts. -The only permitted way to test, build or run the project is through `sh/prod.sh`. ## Tooling Versions And Configurations diff --git a/frontend/.gitignore b/frontend/.gitignore deleted file mode 100644 index 5ef6a52..0000000 --- a/frontend/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# env files (can opt-in for committing if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts diff --git a/frontend/README.md b/frontend/README.md deleted file mode 100644 index e215bc4..0000000 --- a/frontend/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/sh/dev.sh b/sh/dev.sh index 0b1f690..5cc0a5e 100755 --- a/sh/dev.sh +++ b/sh/dev.sh @@ -18,8 +18,18 @@ else echo -e "${GREEN}Node.js version is correct: $NODE_VERSION${NC}" fi +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO_ROOT="$SCRIPT_DIR/.." + +# Start the backend server +cd "$REPO_ROOT/backend" || exit 1 +echo -e "${BLUE}Starting backend server...${NC}" +go run main.go & +BACKEND_PID=$! +echo -e "${GREEN}Backend server started with PID $BACKEND_PID.${NC}" + # Start the frontend dev server from anywhere in the repo -cd "$(dirname "$0")/../frontend" || exit 1 +cd "$REPO_ROOT/frontend" || exit 1 # Install dependencies if [ -f package.json ]; then diff --git a/sh/prod.sh b/sh/prod.sh index 88b72d4..1ed9263 100755 --- a/sh/prod.sh +++ b/sh/prod.sh @@ -151,7 +151,9 @@ rm -rf "${TEMP_DIR}" || handle_error "Failed to clean up local temporary files" echo -e "${GREEN}Deployment process completed!${NC}" # Automatically tail logs after deployment echo -e "${GREEN}Tailing logs...${NC}" -sh "$(dirname "$0")/log.sh" -f +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO_ROOT="$SCRIPT_DIR/.." +sh "$SCRIPT_DIR/log.sh" -f LOG_EXIT_CODE=$? if [ $LOG_EXIT_CODE -eq 130 ]; then echo -e "${YELLOW}Log viewing interrupted by user.${NC}"