chore: add dl makefile (#213)

This commit is contained in:
shenlan 2025-09-14 11:05:17 +08:00 committed by GitHub
parent b928964549
commit e4e88e09b2
2 changed files with 103 additions and 6 deletions

View File

@ -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 || \

88
ui/dl/Makefile Normal file
View File

@ -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)"