|
| 1 | +.PHONY: help |
| 2 | + |
| 3 | +MAKEFLAGS += --silent |
| 4 | +.DEFAULT_GOAL := help |
| 5 | + |
| 6 | +help: ## Show help message |
| 7 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 8 | + |
| 9 | +include .env |
| 10 | + |
| 11 | +setup: ## Prepare stack to run |
| 12 | + cd application && npm install |
| 13 | + cd .github/actions/generate-blog-post && npm install |
| 14 | + cd .github/actions/generate-brand-content && npm install |
| 15 | + cd .github/actions/validate-manifest && npm install |
| 16 | + |
| 17 | +start: ## Start application in dev mode |
| 18 | + cd application && npm run start |
| 19 | + |
| 20 | +lint: ## Run linters |
| 21 | + cd application && npm run lint -- $(filter-out $@,$(MAKECMDGOALS)) |
| 22 | + $(call run_linter,) |
| 23 | + |
| 24 | +lint-fix: ## Run linters |
| 25 | + cd application && npm audit --omit=dev |
| 26 | + cd application && npm run humanize:fix |
| 27 | + cd application && npm run lint:fix |
| 28 | + $(MAKE) linter-fix |
| 29 | + |
| 30 | +build: ## Build libs and applications |
| 31 | + cd application && npm run build |
| 32 | + |
| 33 | +test: ## Run tests |
| 34 | + cd application && npm run test:ci |
| 35 | + cd .github/actions/generate-blog-post && npm run test:ci |
| 36 | + cd .github/actions/generate-brand-content && npm run test:ci |
| 37 | + cd .github/actions/validate-manifest && npm run test:ci |
| 38 | + |
| 39 | +ci: ## Run tests in CI mode |
| 40 | + $(MAKE) lint-fix |
| 41 | + $(MAKE) build |
| 42 | + $(MAKE) test |
| 43 | + |
| 44 | +linter-fix: ## Execute linting and fix |
| 45 | + $(call run_linter, \ |
| 46 | + -e FIX_CSS_PRETTIER=true \ |
| 47 | + -e FIX_JSON_PRETTIER=true \ |
| 48 | + -e FIX_JAVASCRIPT_PRETTIER=true \ |
| 49 | + -e FIX_YAML_PRETTIER=true \ |
| 50 | + -e FIX_MARKDOWN=true \ |
| 51 | + -e FIX_MARKDOWN_PRETTIER=true \ |
| 52 | + -e FIX_NATURAL_LANGUAGE=true) |
| 53 | + |
| 54 | +define run_linter |
| 55 | + DEFAULT_WORKSPACE="$(CURDIR)"; \ |
| 56 | + LINTER_IMAGE="linter:latest"; \ |
| 57 | + VOLUME="$$DEFAULT_WORKSPACE:$$DEFAULT_WORKSPACE"; \ |
| 58 | + docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \ |
| 59 | + docker run \ |
| 60 | + -v $$VOLUME \ |
| 61 | + --rm \ |
| 62 | + -w "$$DEFAULT_WORKSPACE" \ |
| 63 | + -e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \ |
| 64 | + -e GITHUB_WORKSPACE="$$DEFAULT_WORKSPACE" \ |
| 65 | + -e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \ |
| 66 | + -e VALIDATE_TYPESCRIPT_PRETTIER=false \ |
| 67 | + -e VALIDATE_TYPESCRIPT_ES=false \ |
| 68 | + -e VALIDATE_CSS=false \ |
| 69 | + $(1) \ |
| 70 | + $$LINTER_IMAGE |
| 71 | +endef |
| 72 | + |
| 73 | +define docker-compose |
| 74 | + COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.$(1).yml $(2) |
| 75 | +endef |
| 76 | + |
| 77 | +define open-in-browser |
| 78 | + @if command -v x-www-browser &> /dev/null ; then x-www-browser $(1); \ |
| 79 | + elif command -v xdg-open &> /dev/null ; then xdg-open $(1); \ |
| 80 | + elif command -v open &> /dev/null ; then open $(1); \ |
| 81 | + elif command -v start &> /dev/null ; then start $(1); fi; |
| 82 | +endef |
| 83 | + |
| 84 | +############################# |
| 85 | +# Argument fix workaround |
| 86 | +############################# |
| 87 | +%: |
| 88 | + @: |
0 commit comments