fradrive/Makefile

223 lines
5.9 KiB
Makefile

CONTAINER_COMMAND ?= podman
IN_CONTAINER ?= false
IN_CI ?= false
export CONTAINER_COMMAND
export IN_CONTAINER
export IN_CI
db ?= -cf
###########################
##### GENERAL TARGETS #####
.PHONY: help
help:
@echo "Nothing to see here, go away"
.PHONY: all
all:
@echo "TODO"
.PHONY: clean
clean:
rm -rf node_modules .npm .cache assets/icons well-known static/
rm -rf .stack .stack-work .stack-work-build .stack-work-run .stack-work-test .stack-work-doc
rm -rf bin/
.PHONY: release
release:
./.gitlab-ci/version.pl -changelog CHANGELOG.md
git add CHANGELOG.md
VERSION=`.gitlab-ci/version.pl`
git tag ${VERSION}
git commit -m "chore(release): ${VERSION}"
git push
##### GENERAL TARGETS #####
###########################
############################################
##### UNIFIED FRONTEND/BACKEND TARGETS #####
.PHONY: compile
compile: compile-frontend compile-backend
.PHONY: lint
lint: lint-frontend lint-backend
.PHONY: test
test: test-frontend test-backend i18n-check
##### UNIFIED FRONTEND/BACKEND TARGETS #####
############################################
############################
##### FRONTEND TARGETS #####
.PHONY: %-frontend
%-frontend: FRADRIVE_SERVICE=frontend
%-frontend: --image-build --%-frontend;
.PHONY: --%-frontend
--%-frontend: node_modules well-known;
.PHONY: --compile-frontend
--compile-frontend:
npx -- webpack --progress $(WATCH)
.PHONY: --frontend-watch
--frontend-watch: WATCH=--watch
--frontend-watch: --compile-frontend;
.PHONY: --lint-frontend
--lint-frontend: eslint.config.js
npx -- eslint frontend/src $(FIX)
@echo Hooray! There are no hints.
.PHONY: --test-frontend
--test-frontend: karma.conf.cjs
@echo Karma frontend tests are currently broken after npm update and have therefor been temporarily disabled.
# npx -- karma start --conf karma.conf.cjs $(WATCH)
.PHONY: --test-frontend-watch
--test-frontend-watch: WATCH=--single-run false
--test-frontend-watch: --test-frontend;
node_modules: package.json package-lock.json
$(MAKE) -- --image-run---node_modules
.PHONY: --node_modules
--node_modules: package.json package-lock.json
npm ci --cache .npm --prefer-offline
package-lock.json: package.json
$(MAKE) -- --image-run---package-lock.json
.PHONY: --package-lock.json
--package-lock.json: package.json
npm install --cache .npm --prefer-offline
assets: node_modules
$(MAKE) -- --image-run---assets
.PHONY: --assets/icons
--assets: node_modules
./utils/renamer.pl node_modules/@fortawesome/fontawesome-free/svgs/solid utils/rename-fa.json assets/icons/fradrive
./utils/renamer.pl node_modules/@fortawesome/fontawesome-free/svgs/regular utils/rename-fa.json assets/icons/fradrive
well-known: node_modules assets well-known/.well-known
$(MAKE) -- --image-run---well-known
.PHONY: --well-known
--well-known: node_modules assets well-known/.well-known
npx webpack --progress
# mark well-known directory as clean after successful webpack run:
touch well-known/.well-known
well-known/.well-known:
# no-op target
##### FRONTEND TARGETS #####
############################
###########################
##### BACKEND TARGETS #####
.PHONY: %-backend
%-backend: FRADRIVE_SERVICE=backend
%-backend: --image-build --%-backend-dev;
.PHONY: %-backend-prod
%-backend-prod: FRADRIVE_SERVICE=backend
%-backend-prod: --image-build --%-backend-prod;
.PHONY: --%-backend-dev
--%-backend-dev: FRADRIVE_SERVICE=backend
--%-backend-dev: stackopts=--flag uniworx:dev
--%-backend-dev: --image-build --%-backend;
.PHONY: --backend-%-prod
--%-backend-prod: FRADRIVE_SERVICE=backend
--%-backend-prod: stackopts=--flag uniworx:-dev
--%-backend-prod: --image-build --%-backend;
.PHONY: --compile-backend
--compile-backend:
stack build --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only --copy-bins --local-bin-path $$(pwd)/bin $(stackopts)
.PHONY: --lint-backend
--lint-backend:
stack build --test --fast --flag uniworx:library-only uniworx:test:hlint $(stackopts)
.PHONY: --test-backend
--test-backend:
stack build --test --coverage --fast --flag uniworx:library-only $(stackopts)
# TODO: maybe deprecated
.PHONY: database
database: .stack .stack-work.lock compile-backend-prod
export SERVER_SESSION_ACID_FALLBACK=$${SERVER_SESSION_ACID_FALLBACK:-true}
export AVSPASS=$${AVSPASS:-nopasswordset}
stack exec uniworxdb -- $(db)
.PHONY: .stack
.stack: stack.yaml stack.yaml.lock
.stack:
$(MAKE) -- --image-run---.stack
--.stack: stack.yaml stack.yaml.lock
stack build --fast --only-dependencies $(stackopts)
.stack-work.lock:
[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en .stack-work.lock "$0" "$@" || :
##### BACKEND TARGETS #####
###########################
#############################
##### CONTAINER TARGETS #####
.PHONY: --containerized-%-frontend
--containerized-%-frontend: FRADRIVE_SERVICE=frontend
--containerized-%-frontend: --image-build --image-run-%-frontend;
.PHONY: --containerized-%-backend
--containerized-%-backend: FRADRIVE_SERVICE=backend
--containerized-%-backend: --image-build --image-run-%-backend;
.PHONY: image-rebuild
image-rebuild-%:
$(MAKE) -- --image-build FRADRIVE_SERVICE=$* NO_CACHE=--no-cache
.PHONY: --image-build
--image-build:
rm -f .Dockerfile
ln -s docker/$(FRADRIVE_SERVICE)/Dockerfile .Dockerfile
MOUNT_DIR=/mnt/fradrive; \
PROJECT_DIR=/mnt/fradrive; \
if [ "$(IN_CI)" == "true" ] ; then \
PROJECT_DIR=/fradrive; \
fi; \
$(CONTAINER_COMMAND) build $(NO_CACHE) -v $(PWD):$${MOUNT_DIR} --build-arg MOUNT_DIR=$${MOUNT_DIR} --build-arg PROJECT_DIR=$${PROJECT_DIR} --tag $(FRADRIVE_SERVICE) --file $(PWD)/.Dockerfile
.PHONY: --image-run-%
--image-run-%:
ifeq ($(IN_CONTAINER),true)
$(MAKE) -- $*
else
$(CONTAINER_COMMAND) run -v $(PWD):/mnt/fradrive --env FRADRIVE_MAKE_TARGET=$* $(FRADRIVE_SERVICE)
endif
##### CONTAINER TARGETS #####
#############################
.PHONY: i18n-check
i18n-check: --image-run---i18n-check
.PHONY: --i18n-check
--i18n-check:
./missing-translations.sh
@echo No missing translations.
%.lock:
[ -e $@ ] || touch $@
flock -en $@ true