diff --git a/Makefile b/Makefile index c580ee6..4f8f914 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,9 @@ NODE_MAJOR ?= 22 export PATH := $(GO_BIN):$(PATH) .PHONY: install install-openresty install-redis install-postgresql install-pgvector install-zhparser init-db \ - build build-server build-homepage build-panel \ - start start-openresty start-server start-homepage start-panel \ - stop stop-server stop-homepage stop-panel stop-openresty restart + build build-server build-homepage build-panel build-dl \ + start start-openresty start-server start-homepage start-panel start-dl \ + stop stop-server stop-homepage stop-panel stop-dl stop-openresty restart # ----------------------------------------------------------------------------- # Dependency installation @@ -94,7 +94,7 @@ init-db: # Build targets # ----------------------------------------------------------------------------- -build: build-cli build-server build-homepage build-panel +build: build-cli build-server build-homepage build-panel build-dl build-cli: $(MAKE) -C client build @@ -108,11 +108,14 @@ build-homepage: build-panel: $(MAKE) -C ui/panel build +build-dl: + $(MAKE) -C ui/dl build + # ----------------------------------------------------------------------------- # Run targets # ----------------------------------------------------------------------------- -start: start-openresty start-server start-homepage start-panel +start: start-openresty start-server start-homepage start-panel start-dl start-server: $(MAKE) -C server start @@ -123,7 +126,10 @@ start-homepage: start-panel: $(MAKE) -C ui/panel start -stop: stop-server stop-homepage stop-panel stop-openresty +start-dl: + $(MAKE) -C ui/dl start + +stop: stop-server stop-homepage stop-panel stop-dl stop-openresty stop-server: $(MAKE) -C server stop @@ -134,6 +140,9 @@ stop-homepage: stop-panel: $(MAKE) -C ui/panel stop +stop-dl: + $(MAKE) -C ui/dl stop + start-openresty: ifeq ($(OS),Darwin) @brew services start openresty >/dev/null 2>&1 || \ diff --git a/ui/dl/Makefile b/ui/dl/Makefile new file mode 100644 index 0000000..68425e6 --- /dev/null +++ b/ui/dl/Makefile @@ -0,0 +1,88 @@ +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) + +.PHONY: init dev build export clean info icon start stop restart test + +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) ../logo.png -resize 32x32 public/icons/cloudnative_32.png + @$(MAGICK) ../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 dl..." + @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 install + +dev: + @echo "๐Ÿš€ Starting Next.js dev server (dl)..." + yarn next dev -p 3002 + +start: + @echo "๐Ÿš€ Starting Next.js dev server (dl) in background..." + @nohup yarn next dev -p 3002 >/tmp/dl.log 2>&1 & echo $$! > dl.pid + +stop: + @echo "๐Ÿ›‘ Stopping Next.js dev server (dl)..." + @if [ -f dl.pid ]; then \ + kill `cat dl.pid` >/dev/null 2>&1 || true; \ + rm dl.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 + @echo "๐Ÿ”จ Building dl..." + yarn next build + +export: + @echo "๐Ÿ“ฆ Exporting dl static site to ./out ..." + yarn next export + +clean: + @echo "๐Ÿงน Cleaning .next and out directories..." + rm -rf .next out + +info: + @echo "๐Ÿงพ Node.js version: $(NODE_VERSION)" +