Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make script dash compatible #1165

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,65 @@
#!/bin/bash
# Check Node.js version
#!/bin/sh

# Node.js version check
REQUIRED_NODE_VERSION=22
CURRENT_NODE_VERSION=$(node -v | cut -d'.' -f1 | sed 's/v//')

if (( CURRENT_NODE_VERSION < REQUIRED_NODE_VERSION && CURRENT_NODE_VERSION < 23 )); then
echo "Error: Node.js version must be $REQUIRED_NODE_VERSION or 23 or higher. Current version is $CURRENT_NODE_VERSION."
# Compare Node versions
if [ "$(expr "$CURRENT_NODE_VERSION" \< "$REQUIRED_NODE_VERSION")" -eq 1 ]; then
echo "\033[1;31mError: Node.js version must be $REQUIRED_NODE_VERSION or higher. Current version is $CURRENT_NODE_VERSION.\033[0m"

Check notice on line 9 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L9

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi

# Check if pnpm is installed
if ! command -v pnpm >/dev/null 2>&1; then
echo "\033[1;31mError: pnpm is not installed. Please install pnpm before running the script.\033[0m"

Check notice on line 15 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L15

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi

# Navigate to project root
cd "$(dirname "$0")"/..
cd "$(dirname "$0")"/.. || exit 1

# clean cache
echo -e "\033[1mCleaning cache...\033[0m"
# Clean cache
echo "\033[1mCleaning cache...\033[0m"

Check notice on line 23 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L23

echo may not expand escape sequences. Use printf. (SC2028)
if ! pnpm clean; then
echo -e "\033[1;31mFailed to clean cache\033[0m"
echo "\033[1;31mFailed to clean cache.\033[0m"

Check notice on line 25 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L25

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi


# Install dependencies
echo -e "\033[1mInstalling dependencies...\033[0m"
if ! pnpm i ; then
echo -e "\033[1;31mFailed to install dependencies\033[0m"
echo "\033[1mInstalling dependencies...\033[0m"

Check notice on line 30 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L30

echo may not expand escape sequences. Use printf. (SC2028)
if ! pnpm install; then
echo "\033[1;31mFailed to install dependencies.\033[0m"

Check notice on line 32 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L32

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi

# Build project
echo -e "\033[1mBuilding project...\033[0m"
echo "\033[1mBuilding project...\033[0m"

Check notice on line 37 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L37

echo may not expand escape sequences. Use printf. (SC2028)
if ! pnpm build; then
echo -e "\033[1;31mFailed to build project\033[0m"
echo "\033[1;31mFailed to build project.\033[0m"

Check notice on line 39 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L39

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi

# Start project
echo -e "\033[1mStarting project...\033[0m"
echo "\033[1mStarting project...\033[0m"

Check notice on line 44 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L44

echo may not expand escape sequences. Use printf. (SC2028)
if ! pnpm start; then
echo -e "\033[1;31mFailed to start project\033[0m"
echo "\033[1;31mFailed to start project.\033[0m"

Check notice on line 46 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L46

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi

# Start client
echo -e "\033[1mStarting client...\033[0m"
pnpm start:client
echo "\033[1mStarting client...\033[0m"

Check notice on line 51 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L51

echo may not expand escape sequences. Use printf. (SC2028)
if ! pnpm start:client; then
echo "\033[1;31mFailed to start client.\033[0m"

Check notice on line 53 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L53

echo may not expand escape sequences. Use printf. (SC2028)
exit 1
fi

# Open webpage
echo -e "\033[1mOpening webpage...\033[0m"
if command -v xdg-open &> /dev/null; then
xdg-open http://localhost:5173
elif command -v open &> /dev/null; then
open http://localhost:5173
echo "\033[1mOpening webpage at http://localhost:5173...\033[0m"

Check notice on line 58 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L58

echo may not expand escape sequences. Use printf. (SC2028)
if command -v xdg-open >/dev/null 2>&1; then
xdg-open "http://localhost:5173"
elif command -v open >/dev/null 2>&1; then
open "http://localhost:5173"
else
echo -e "\033[1;33mPlease open http://localhost:5173 in your browser\033[0m"
echo "\033[1;33mPlease open http://localhost:5173 in your browser.\033[0m"

Check notice on line 64 in scripts/start.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/start.sh#L64

echo may not expand escape sequences. Use printf. (SC2028)
fi
Loading