Files
compiler-explorer/Makefile
T
2022-01-17 17:28:45 -06:00

70 lines
2.9 KiB
Makefile

default: run
help: # with thanks to Ben Rady
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# If you see "node-not-found" then you need to depend on node-installed.
NODE:=node-not-found
NPM:=npm-not-found
# These 'find' scripts cache their results in a dotfile.
# Doing it this way instead of NODE:=$(shell etc/script/find-node) means
# if they fail, they stop the make process. As best I can tell there's no
# way to get make to fail if a sub-shell command fails.
.node-bin: etc/scripts/find-node
@etc/scripts/find-node .node-bin
# All targets that need node must depend on this to ensure the NODE variable
# is appropriately set, and that PATH is updated.
node-installed: .node-bin
@$(eval NODE:=$(shell cat .node-bin))
@$(eval NPM:=$(shell dirname $(shell cat .node-bin))/npm)
@$(eval PATH=$(shell dirname $(realpath $(NODE))):$(PATH))
info: node-installed ## print out some useful variables
@echo Using node from $(NODE)
@echo Using npm from $(NPM)
@echo PATH is $(PATH)
.PHONY: clean run test run-amazon
.PHONY: dist lint lint-fix ci-lint prereqs node_modules gh-dist check pre-commit
prereqs: node_modules
NODE_MODULES=./node_modules/.npm-updated
$(NODE_MODULES): package.json | node-installed
$(NPM) install $(NPM_FLAGS)
@rm -rf node_modules/.cache/esm/*
@touch $@
lint: $(NODE_MODULES) ## Checks if the source currently matches code conventions
$(NPM) run ts-compile
$(NPM) run lint
lint-fix: $(NODE_MODULES) ## Checks if everything matches code conventions & fixes those which are trivial to do so
$(NPM) run lint-fix
ci-lint: $(NODE_MODULES)
$(NPM) run ci-lint
node_modules: $(NODE_MODULES)
test: $(NODE_MODULES) ## Runs the tests
$(NPM) run test
@echo Tests pass
check: $(NODE_MODULES) test lint ## Runs all checks required before committing (fixing trivial things automatically)
pre-commit: $(NODE_MODULES) test ci-lint
clean: ## Cleans up everything
rm -rf node_modules .*-updated .*-bin out
run: prereqs ## Runs the site normally
$(NPM) run webpack
./node_modules/.bin/supervisor -w app.js,lib,etc/config,static/tsconfig.json -e 'js|ts|node|properties|yaml' --exec $(NODE) $(NODE_ARGS) -- -r esm -r ts-node/register ./app.js $(EXTRA_ARGS)
dev: prereqs ## Runs the site as a developer; including live reload support and installation of git hooks
./node_modules/.bin/supervisor -w app.js,lib,etc/config,static/tsconfig.json -e 'js|ts|node|properties|yaml' -n exit --exec $(NODE) $(NODE_ARGS) -- -r esm -r ts-node/register ./app.js $(EXTRA_ARGS)
debug: prereqs ## Runs the site as a developer with full debugging; including live reload support and installation of git hooks
./node_modules/.bin/supervisor -w app.js,lib,etc/config,static/tsconfig.json -e 'js|ts|node|properties|yaml' -n exit --inspect 9229 --exec $(NODE) $(NODE_ARGS) -- -r esm -r ts-node/register ./app.js --debug $(EXTRA_ARGS)