SHELL := /bin/bash NODE_VERSION := $(shell node -v 2>/dev/null || echo "Not Found") YARN := $(shell command -v yarn 2>/dev/null) MAGICK := $(shell command -v magick 2>/dev/null || command -v convert 2>/dev/null) OS := $(shell uname -s) YARN_VERSION ?= 4.12.0 .PHONY: init ensure-deps dev build export clean info icon start stop restart test sync-dl-index icon: @echo "๐ŸŽจ Generating favicon and icon images..." @if [ -z "$(MAGICK)" ]; then \ echo "โŒ ImageMagick not found."; \ if [ "$(OS)" = "Darwin" ]; then \ echo "๐Ÿ‘‰ Try: brew install imagemagick"; \ elif [ -f /etc/debian_version ]; then \ echo "๐Ÿ‘‰ Try: sudo apt install imagemagick"; \ elif [ -f /etc/redhat-release ]; then \ echo "๐Ÿ‘‰ Try: sudo dnf install imagemagick"; \ fi; \ exit 1; \ fi @mkdir -p public/icons @$(MAGICK) ../ui/logo.png -resize 32x32 public/icons/cloudnative_32.png @$(MAGICK) ../ui/logo.png -resize 64x64 -background none -define icon:auto-resize=64,48,32,16 public/favicon.ico @echo "โœ… Icons generated successfully." init: @echo "๐Ÿ”ง Installing dependencies for dashboard..." @corepack enable && corepack prepare yarn@$(YARN_VERSION) --activate @echo "๐Ÿงน Removing npm lockfiles to mirror Docker build..." @find . -name "package-lock.json" -delete @if [ -z "$(YARN)" ]; then \ echo "โš ๏ธ Yarn not found. Attempting to install..."; \ if [ "$(OS)" = "Darwin" ]; then \ if command -v brew >/dev/null 2>&1; then \ brew install yarn; \ else \ echo "โŒ Homebrew not found. Please install Yarn manually."; exit 1; \ fi; \ elif [ -f /etc/debian_version ]; then \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \ sudo apt update && sudo apt install -y yarn; \ elif [ -f /etc/redhat-release ]; then \ curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo && \ sudo yum install -y yarn; \ else \ echo "โŒ Unsupported OS. Please install Yarn manually."; exit 1; \ fi; \ fi yarn config set npmRegistryServer https://registry.npmmirror.com yarn install --immutable ensure-deps: @if [ ! -f .yarn/install-state.gz ] || [ ! -d node_modules ] || [ ! -d node_modules/sanitize-html ]; then \ echo "๐Ÿ“ฆ Installing dependencies..."; \ yarn install --immutable; \ fi dev: ensure-deps @echo "Starting Next.js dev server (dashboard)..." @echo "/editor is proxied to an external NeuraPress front-end at http://localhost:4000." yarn dev -p 3001 start: @echo "๐Ÿš€ Starting Next.js dev server (dashboard) in background..." @nohup yarn dev -p 3001 >/tmp/dashboard.log 2>&1 & echo $$! > dashboard.pid stop: @echo "๐Ÿ›‘ Stopping Next.js dev server (dashboard)..." @if [ -f dashboard.pid ]; then \ kill `cat dashboard.pid` >/dev/null 2>&1 || true; \ rm dashboard.pid; \ else \ echo "No running server"; \ fi restart: stop start test: @echo "๐Ÿ” Running tests..." @yarn test || echo "No tests configured" build: init yarn config set npmRegistryServer https://registry.npmmirror.com @if [ -z "$(SKIP_SYNC)" ]; then \ $(MAKE) sync-dl-index; \ fi @echo "๐Ÿ”จ Building dashboard..." yarn prebuild NEXT_TELEMETRY_DISABLED=1 NEXT_PRIVATE_TURBOPACK=1 yarn next build sync-dl-index: @echo "๐Ÿ“ฅ Fetching download & docs manifests..." @mkdir -p public/dl-index @if ! curl -fsSL https://dl.svc.plus/manifest.json -o public/dl-index/artifacts-manifest.json; then \ echo "โš ๏ธ Unable to download artifacts manifest. Using existing snapshot."; \ fi @if ! curl -fsSL https://dl.svc.plus/docs/all.json -o public/dl-index/docs-manifest.json; then \ echo "โš ๏ธ Unable to download docs manifest. Using existing snapshot."; \ fi export: @echo "๐Ÿ“ฆ Exporting dashboard static site to ./out ..." @NEXT_SHOULD_EXPORT=true yarn next export clean: @echo "๐Ÿงน Cleaning .next and out directories..." rm -rf .next out info: @echo "๐Ÿงพ Node.js version: $(NODE_VERSION)"