Skip to content
41 changes: 41 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
#!/bin/bash

REQUIRED_NODE_VERSION=22.9.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're not strict on Node 22.9. It can be anything above 22 (for now).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yarn does need to be 1.22.22 at least.

REQUIRED_YARN_VERSION=1.22.22

version_ge() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this supposed to be version_get?
Or maybe you meant greater-than or equal-to.

IMO naming the function compare_version or version_at_least or something more obvious would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now changed it to version_at_least

[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ]
}

# Check Node.js version
check_node_version() {
if ! command -v node &> /dev/null; then
echo "Node.js is not installed. Please install Node.js v$REQUIRED_NODE_VERSION or higher."
exit 1
fi

NODE_VERSION=$(node -v | sed 's/v//')
if ! version_ge "$NODE_VERSION" "$REQUIRED_NODE_VERSION"; then
echo "Current Node.js version ($NODE_VERSION) is incompatible. Please install v$REQUIRED_NODE_VERSION or higher."
exit 1
fi
}

# Check Yarn version
check_yarn_version() {
if ! command -v yarn &> /dev/null; then
echo "Yarn is not installed. Please install Yarn v$REQUIRED_YARN_VERSION or higher."
exit 1
fi

YARN_VERSION=$(yarn -v)
if ! version_ge "$YARN_VERSION" "$REQUIRED_YARN_VERSION"; then
echo "Current Yarn version ($YARN_VERSION) is incompatible. Please install v$REQUIRED_YARN_VERSION or higher."
exit 1
fi
}

check_node_version
check_yarn_version

echo "Node.js and Yarn versions are compatible. Proceeding..."


[ ! -f .env ] && cp env.example .env

check_internet_connection() {
Expand Down