|
1 | 1 | PORT ?= 4017 |
2 | 2 | BIND ?= 0.0.0.0 |
| 3 | +RUBY_VERSION_REQUIRED ?= 3.4 |
| 4 | +NODE_VERSION_REQUIRED ?= 22 |
3 | 5 |
|
4 | | -.PHONY: install frontend build start clean website-install website-frontend website-build website-start |
| 6 | +.DEFAULT_GOAL := help |
| 7 | + |
| 8 | +export RUBY_VERSION_REQUIRED |
| 9 | +export NODE_VERSION_REQUIRED |
| 10 | + |
| 11 | +.PHONY: help doctor install frontend frontend-watch build test lint ci-local pre-release verify-cli-release verify-hospital-tutorial start clean version |
| 12 | + |
| 13 | +define status |
| 14 | + @printf '\n==> %s\n' "$(1)" |
| 15 | +endef |
| 16 | + |
| 17 | +help: |
| 18 | + @printf 'SolverForge.org Bridgetown site\n\n' |
| 19 | + @printf 'Setup\n' |
| 20 | + @printf ' make doctor Verify local Ruby, Bundler, Node, and npm\n' |
| 21 | + @printf ' make install Install Ruby gems and Node packages\n' |
| 22 | + @printf '\nBuild and run\n' |
| 23 | + @printf ' make frontend Build esbuild assets\n' |
| 24 | + @printf ' make frontend-watch Watch esbuild assets during development\n' |
| 25 | + @printf ' make build Build frontend assets and Bridgetown output\n' |
| 26 | + @printf ' make start Serve locally on BIND=%s PORT=%s\n' "$(BIND)" "$(PORT)" |
| 27 | + @printf ' make clean Remove Bridgetown build output\n' |
| 28 | + @printf '\nQuality gates\n' |
| 29 | + @printf ' make test Build in test mode and verify the hospital tutorial\n' |
| 30 | + @printf ' make lint Run Ruby and JavaScript syntax checks\n' |
| 31 | + @printf ' make verify-cli-release Install the published CLI and verify scaffold targets\n' |
| 32 | + @printf ' make verify-hospital-tutorial Run portable tutorial contract checks\n' |
| 33 | + @printf ' make ci-local Run the same gate used by CI\n' |
| 34 | + @printf ' make pre-release Run the release-readiness gate\n' |
| 35 | + @printf '\nInspection\n' |
| 36 | + @printf ' make version Print toolchain and site tool versions\n' |
| 37 | + |
| 38 | +doctor: |
| 39 | + $(call status,Checking required tools) |
| 40 | + @command -v ruby >/dev/null || { printf 'missing required command: ruby\n' >&2; exit 1; } |
| 41 | + @command -v bundle >/dev/null || { printf 'missing required command: bundle\n' >&2; exit 1; } |
| 42 | + @command -v node >/dev/null || { printf 'missing required command: node\n' >&2; exit 1; } |
| 43 | + @command -v npm >/dev/null || { printf 'missing required command: npm\n' >&2; exit 1; } |
| 44 | + @ruby -e 'required = ENV.fetch("RUBY_VERSION_REQUIRED"); actual = RUBY_VERSION; abort("Ruby #{required}.x required; found #{actual}") unless actual.start_with?("#{required}.")' |
| 45 | + @node -e 'const required = process.env.NODE_VERSION_REQUIRED; const actual = process.versions.node; if (!actual.startsWith(`$${required}.`)) { console.error(`Node $${required}.x required; found $${actual}`); process.exit(1); }' |
| 46 | + @printf 'Ruby: '; ruby -v |
| 47 | + @printf 'Bundler: '; bundle -v |
| 48 | + @printf 'Node: '; node -v |
| 49 | + @printf 'npm: '; npm -v |
5 | 50 |
|
6 | 51 | install: |
7 | | - bundle install |
8 | | - npm install |
| 52 | + $(call status,Installing Ruby gems) |
| 53 | + @bundle install |
| 54 | + $(call status,Installing Node packages) |
| 55 | + @npm ci |
9 | 56 |
|
10 | 57 | frontend: |
11 | | - bundle exec rake frontend:build |
| 58 | + $(call status,Building frontend assets) |
| 59 | + @bundle exec rake frontend:build |
| 60 | + |
| 61 | +frontend-watch: |
| 62 | + $(call status,Watching frontend assets) |
| 63 | + @bundle exec rake frontend:dev |
12 | 64 |
|
13 | 65 | build: frontend |
14 | | - bundle exec bridgetown build |
| 66 | + $(call status,Building Bridgetown site) |
| 67 | + @bundle exec bridgetown build |
15 | 68 |
|
16 | | -start: |
17 | | - bundle exec bridgetown start -P $(PORT) -B $(BIND) |
| 69 | +test: frontend |
| 70 | + $(call status,Building Bridgetown site in test mode) |
| 71 | + @BRIDGETOWN_ENV=test bundle exec rake test |
| 72 | + $(call status,Verifying hospital tutorial contract) |
| 73 | + @ruby scripts/verify-hospital-tutorial.rb |
18 | 74 |
|
19 | | -clean: |
20 | | - bundle exec bridgetown clean |
| 75 | +lint: |
| 76 | + $(call status,Checking Ruby syntax) |
| 77 | + @ruby -c Gemfile |
| 78 | + @ruby -c Rakefile |
| 79 | + @find . \( -path './.git' -o -path './.bridgetown-cache' -o -path './node_modules' -o -path './output' -o -path './vendor' \) -prune -o -name '*.rb' -print0 | xargs -0 -n 1 ruby -c |
| 80 | + $(call status,Checking JavaScript syntax) |
| 81 | + @find . \( -path './.git' -o -path './.bridgetown-cache' -o -path './node_modules' -o -path './output' -o -path './vendor' \) -prune -o \( -name '*.js' -o -name '*.mjs' \) -print0 | xargs -0 -n 1 node --check |
| 82 | + |
| 83 | +ci-local: doctor lint build verify-hospital-tutorial |
| 84 | + |
| 85 | +pre-release: verify-cli-release ci-local |
| 86 | + $(call status,Ready for release) |
21 | 87 |
|
22 | | -website-install: install |
| 88 | +verify-cli-release: |
| 89 | + $(call status,Verifying published solverforge-cli release) |
| 90 | + @ruby scripts/verify-cli-release.rb |
23 | 91 |
|
24 | | -website-frontend: frontend |
| 92 | +verify-hospital-tutorial: |
| 93 | + $(call status,Verifying hospital tutorial contract) |
| 94 | + @ruby scripts/verify-hospital-tutorial.rb |
25 | 95 |
|
26 | | -website-build: build |
| 96 | +start: |
| 97 | + $(call status,Starting Bridgetown on $(BIND):$(PORT)) |
| 98 | + @bundle exec bridgetown start -P $(PORT) -B $(BIND) |
| 99 | + |
| 100 | +clean: |
| 101 | + $(call status,Cleaning Bridgetown output) |
| 102 | + @bundle exec bridgetown clean |
27 | 103 |
|
28 | | -website-start: start |
| 104 | +version: |
| 105 | + $(call status,Tool versions) |
| 106 | + @printf 'Ruby: '; ruby -v |
| 107 | + @printf 'Bundler: '; bundle -v |
| 108 | + @printf 'Node: '; node -v |
| 109 | + @printf 'npm: '; npm -v |
| 110 | + @printf 'Bridgetown: '; bundle exec bridgetown -v |
0 commit comments