-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (83 loc) · 3.66 KB
/
Copy pathMakefile
File metadata and controls
94 lines (83 loc) · 3.66 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
# Semantic Firewall User Guide — packaging targets
#
# Produces customer-ready deliverables under dist/ (gitignored):
# - dist/semantic-firewall-user-guide-YYYY-MM-DD.zip (static site, opens locally)
# - dist/semantic-firewall-user-guide-YYYY-MM-DD.pdf (single PDF of all pages)
#
# Both formats are offline-friendly. The zip extracts to a folder; open
# index.html in any browser — the full sidebar + client-side search works
# with no server. The PDF is one printable file with every page.
#
# All paths are anchored to ROOT (this Makefile's directory). No relative
# cd anywhere — recipes work regardless of where `make` is invoked from
# (`make -C ...`, `make -f /abs/Makefile`, etc.).
ROOT := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
DATE := $(shell date +%Y-%m-%d)
PACKAGE := semantic-firewall-user-guide-$(DATE)
DIST := $(ROOT)/dist
ZIP := $(DIST)/$(PACKAGE).zip
PDF := $(DIST)/$(PACKAGE).pdf
# Staging copy of dist/ with URLs rewritten for file:// browsing. Lives
# outside dist/ so the PDF target keeps using the unmodified build.
STAGE := $(ROOT)/.zip-staging
.PHONY: help install dev build zip pdf package release clean
help:
@echo "Semantic Firewall User Guide — make targets"
@echo
@echo " install First-time setup: npm install + playwright chromium"
@echo " (chromium download is ~150 MB; only needed for PDF)"
@echo " dev Start the Astro dev server with HMR at http://localhost:4321"
@echo " build Run Astro build → $(DIST)/"
@echo " zip build + produce $(ZIP)"
@echo " pdf build + produce $(PDF)"
@echo " package build + both artefacts"
@echo " release tag + publish a GitHub Release of the current commit"
@echo " using the semver in ./VERSION (edit + commit first)"
@echo " clean remove $(DIST)/"
@echo
@echo "Send the resulting .zip and .pdf to a customer — both artefacts are"
@echo "self-contained and offline-friendly."
install:
cd $(ROOT) && npm install
cd $(ROOT) && npx playwright install chromium
# Astro dev server with HMR. Default port 4321 (see package.json).
# Foregrounds the process; Ctrl-C to stop.
dev:
cd $(ROOT) && npm run dev
build:
cd $(ROOT) && npm run build
# zip target stages a copy of dist/ with server-absolute URLs rewritten to
# page-relative form (so customers can double-click index.html and read it
# without running a web server), then archives the staging dir. The zip is
# written to ROOT first and moved into DIST to avoid the recursive-archive
# pattern (zipping a directory while writing the archive into that same
# directory).
zip: build
@echo "▶ preparing offline-portable HTML for ZIP…"
rm -rf $(STAGE)
cd $(ROOT) && node $(ROOT)/scripts/prepare-zip.mjs $(DIST) $(STAGE)
@echo "▶ packaging zip…"
cd $(STAGE) && zip -rq $(ROOT)/$(PACKAGE).zip . -x '*.zip' '*.pdf'
mv $(ROOT)/$(PACKAGE).zip $(ZIP)
rm -rf $(STAGE)
@echo "→ $(ZIP) ($$(du -h $(ZIP) | cut -f1))"
pdf: build
@if [ ! -d $(ROOT)/node_modules/playwright ] || [ ! -d $(ROOT)/node_modules/pdf-lib ]; then \
echo "❌ Missing devDependencies. Run: make install"; \
exit 1; \
fi
@echo "▶ packaging pdf…"
cd $(ROOT) && node $(ROOT)/scripts/build-pdf.mjs "$(PDF)"
@echo "→ $(PDF) ($$(du -h $(PDF) | cut -f1))"
package: zip pdf
@echo
@echo "✓ customer deliverables ready:"
@ls -lh $(ZIP) $(PDF)
# release delegates the heavy lifting to scripts/release.sh so the Makefile
# stays declarative. The script reads ./VERSION, validates clean state,
# rebuilds artefacts with version-stamped names, tags + pushes the commit,
# and publishes a GitHub Release with the zip + pdf attached.
release:
bash $(ROOT)/scripts/release.sh
clean:
rm -rf $(DIST) $(STAGE)