Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use taskfile instead of a makefile in the enterprise dev #1047

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions enterprise/frontend/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: "3"

vars:
PM: pnpm
BUILD_DIR: .build
COMMUNITY_DIR: ../../frontend
ENTERPRISE_DIR: ../../enterprise/frontend
FRONTEND_DIR: "{{.BUILD_DIR}}/frontend"
ARTIFACTS: ["{{.BUILD_DIR}}", "node_modules", "package.json", "build"]
.DEFAULT_GOAL: build-enterprise

tasks:
ensure-pnpm:
cmds:
- command -v pnpm || npm install -g pnpm

pre-build:
deps: [ensure-pnpm]
cmds:
- mkdir -p "{{.BUILD_DIR}}"
- rsync -av --exclude="{{.COMMUNITY_DIR}}/build/" --exclude="node_modules/" {{.COMMUNITY_DIR}} {{.BUILD_DIR}}
- rsync -avI --exclude=Taskfile.yml --exclude=Makefile --exclude=Dockerfile --exclude=README.md {{.ENTERPRISE_DIR}} {{.BUILD_DIR}}
- "{{.PM}} install --frozen-lockfile -C {{.FRONTEND_DIR}}"

build-enterprise:
deps: [pre-build]
cmds:
- "{{.PM}} run -C {{.FRONTEND_DIR}} build"
- rsync -av "{{.FRONTEND_DIR}}/build" "{{.ENTERPRISE_DIR}}/build"
- rsync -av "{{.FRONTEND_DIR}}/node_modules" "{{.ENTERPRISE_DIR}}/node_modules"
- rsync -av "{{.FRONTEND_DIR}}/package.json" "{{.ENTERPRISE_DIR}}/package.json"

watch:
silent: true
cmds:
- |
fswatch --batch-marker='EOF' -xn ./src ../../frontend | while read file event; do
if [ "$$file" = "EOF" ]; then
task copy_files CHANGED_FILES="$$list"
list=()
else
basename_file="$$(basename "$$file")"
if [[ "$$file" != *~ ]] && [[ ! "$$basename_file" =~ ^[0-9]+$$ ]] && [[ ! "$$basename_file" =~ ^\. ]] && ! git check-ignore -q "$$file"; then
echo "Tracking: $$file $$event"
list+=("$$file")
fi
fi
done

copy_files:
silent: true
vars:
CHANGED_FILES: []
cmds:
- |
for file in {{range .CHANGED_FILES}}{{.}} {{end}}; do
if [ -n "$$file" ]; then
relative_path="$${file#*/frontend/}"
target_dir="{{.FRONTEND_DIR}}/$$(dirname "$$relative_path")"
mkdir -p "$$target_dir"
rsync -av "$${file}" "$$target_dir"
echo "Copied $$file to $$target_dir"
fi
done

dev:
preconditions:
- sh: "[ -d .build/frontend ] || task pre-build"
cmds:
- "{{.PM}} -C {{.FRONTEND_DIR}} run dev &"
- "task watch &"
- "wait"

clean:
cmds:
- rm -rf {{range .ARTIFACTS}}{{.}} {{end}}
Loading