
.PHONY: all
all: help

.PHONY: help
help:
	@M=$$(perl -ne 'm/((\w|-)*):.*##/ && print length($$1)."\n"' Makefile | \
		sort -nr | head -1) && \
		perl -ne "m/^((\w|-)*):.*##\s*(.*)/ && print(sprintf(\"%s: %s\t%s\n\", \$$1, \" \"x($$M-length(\$$1)), \$$3))" Makefile

./node_modules/.yarn-integrity: package.json
	yarn install

./build/asset-manifest.json: ./node_modules/.yarn-integrity src/App.tsx src/cards/Cards.tsx src/cards/Card.tsx
	yarn build

.PHONY: install
install: ./node_modules/.yarn-integrity  ## Install any yarn packages necessary

.PHONY: build
build: ./build/asset-manifest.json  ## Build the package if it is out of date

.PHONY: serve
serve: build/asset-manifest.json  ## Do everything necessary to run an optimized build
	yarn run http-server build/

.PHONY: dev
dev: ./node_modules/.yarn-integrity  ## Run the server in "dev" mode, with hot reload
	yarn start

.PHONY: dockerize
dockerize:  ## Generate a docker image with an optimized build and a simple fileserver
	docker build --tag elderscrolling:1.0 .

