diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..81eeff3 --- /dev/null +++ b/start.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" +cd -- "$repo_dir" + +if ! command -v node >/dev/null 2>&1; then + printf '%s\n' 'Error: Node.js >=18 is required. Install Node.js and try again.' >&2 + exit 1 +fi + +if ! node -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 18 ? 0 : 1)'; then + printf '%s\n' 'Error: Node.js >=18 is required. Upgrade Node.js and try again.' >&2 + exit 1 +fi + +if ! command -v npm >/dev/null 2>&1; then + printf '%s\n' 'Error: npm is required. Install npm and try again.' >&2 + exit 1 +fi + +if [[ ! -d node_modules ]] || ! npm ls --depth=0 --omit=optional >/dev/null 2>&1; then + printf '%s\n' 'Error: Dependencies are missing or invalid. Run:' >&2 + printf ' cd %q && npm ci\n' "$repo_dir" >&2 + exit 1 +fi + +printf '%s\n' 'Starting Nodecast TV: http://localhost:3000' +exec npm run dev