-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (98 loc) · 3.57 KB
/
Makefile
File metadata and controls
128 lines (98 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
PORT ?= 8080
LOCAL_PORT ?= 8081
LOCAL_PHP ?= php84
DEFAULT_BRANCH ?= MOODLE_500_STABLE
JOBS ?= 2
# Auto-detect PHP 8.3 binary: check Homebrew paths (Apple Silicon, Intel), then system php
PHP_BIN ?= $(or \
$(wildcard /opt/homebrew/opt/php@8.3/bin/php),\
$(wildcard /usr/local/opt/php@8.3/bin/php),\
$(shell command -v php 2>/dev/null))
export PHP_BIN
# Verify PHP 8.3 is available
check-php:
@if [ -z "$(PHP_BIN)" ]; then \
echo "ERROR: No PHP binary found. Install PHP 8.3 via: brew install php@8.3"; \
exit 1; \
fi
@PHP_VER=$$($(PHP_BIN) -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;' 2>/dev/null); \
if [ "$$PHP_VER" != "8.3" ]; then \
echo "ERROR: PHP 8.3 required but $(PHP_BIN) is PHP $$PHP_VER"; \
echo "Install PHP 8.3 via: brew install php@8.3"; \
exit 1; \
fi
@echo "Using PHP 8.3: $(PHP_BIN)"
.PHONY: deps build-version build-worker bundle bundle-all bundle-all-pretty bundle-legacy prepare prepare-dev prepare-dev-pretty prepare-all serve up up-local clean reset check-php test test-e2e test-e2e-chrome test-e2e-firefox lint format
.PHONY: bundle-MOODLE_404_STABLE bundle-MOODLE_405_STABLE bundle-MOODLE_500_STABLE bundle-MOODLE_501_STABLE bundle-MOODLE_502_STABLE bundle-main
deps:
npm install
build-version:
npm run build:version
build-worker:
npm run build:worker
# Fast prepare for local iteration: install deps and rebuild the worker bundle only.
prepare: deps build-version build-worker
# Prepare a local dev runtime: worker + one Moodle branch bundle.
prepare-dev: deps build-version build-worker bundle
# Prepare the local dev runtime with colorized parallel output for the worker and bundle.
prepare-dev-pretty: deps build-version check-php
npm run prepare:dev:pretty
# Full prepare for CI/release: worker + all Moodle bundles.
prepare-all: deps build-version build-worker bundle-all
# Build one branch (defaults to DEFAULT_BRANCH, override with BRANCH=...).
bundle: check-php
BRANCH=$${BRANCH:-$(DEFAULT_BRANCH)} npm run bundle
# Build all branches; use independent per-branch targets so recursive make can parallelize safely.
bundle-all: check-php
$(MAKE) --no-print-directory -j $(JOBS) \
bundle-MOODLE_404_STABLE \
bundle-MOODLE_405_STABLE \
bundle-MOODLE_500_STABLE \
bundle-MOODLE_501_STABLE \
bundle-MOODLE_502_STABLE \
bundle-main
# Colorized multi-branch build for local use.
bundle-all-pretty: deps check-php
npm run bundle:all:pretty
# Legacy single-branch build via CHANNEL (backward compat)
bundle-legacy:
CHANNEL=stable500 npm run bundle
# Per-branch bundle targets
bundle-MOODLE_404_STABLE:
BRANCH=MOODLE_404_STABLE npm run bundle
bundle-MOODLE_405_STABLE:
BRANCH=MOODLE_405_STABLE npm run bundle
bundle-MOODLE_500_STABLE:
BRANCH=MOODLE_500_STABLE npm run bundle
bundle-MOODLE_501_STABLE:
BRANCH=MOODLE_501_STABLE npm run bundle
bundle-MOODLE_502_STABLE:
BRANCH=MOODLE_502_STABLE GIT_REF=v5.2.0 npm run bundle
bundle-main:
BRANCH=main npm run bundle
serve:
PORT=$(PORT) npm run serve
up: deps build-version build-worker bundle-all-pretty serve
up-local: deps build-version bundle
BRANCH=$${BRANCH:-$(DEFAULT_BRANCH)} ./scripts/setup-local.sh $(LOCAL_PORT) $(LOCAL_PHP)
test:
node --test tests/**/*.test.js
test-e2e:
npm run test:e2e
test-e2e-chrome:
npx playwright test --project=chromium
test-e2e-firefox:
npx playwright test --project=firefox
lint:
npx @biomejs/biome check
format:
npx @biomejs/biome check --fix
clean:
rm -rf .cache
rm -rf assets/moodle
rm -f assets/manifests/latest.json
rm -f assets/manifests/MOODLE_*.json
rm -f assets/manifests/main.json
touch assets/manifests/.gitkeep
reset: clean
rm -rf dist