SHELL=bash export CONTAINER_COMMAND ?= podman export IN_CONTAINER ?= false export IN_CI ?= false export WATCH export db ?= -cf export DEV_PORT_HTTP export DEV_PORT_HTTPS ########################### ##### 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: serve serve: $(MAKE) serve-database & $(MAKE) serve-frontend & $(MAKE) serve-backend .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 --containerized-%-frontend; .PHONY: --%-frontend #--%-frontend: node_modules well-known; #--%-frontend: --containerized---node_modules-frontend --containerized---well-known-frontend; --%-frontend: --containerized---frontend-dependencies-frontend; .PHONY: --compile-frontend --compile-frontend: npx -- webpack --progress $(WATCH) .PHONY: --serve-frontend --serve-frontend: WATCH=--watch --serve-frontend: --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) ## TODO: rewrite #.PHONY: --test-frontend-watch #--test-frontend-watch: WATCH=--single-run false #--test-frontend-watch: --test-frontend; # #node_modules: package.json package-lock.json # $(MAKE) -- --containerized---node_modules-frontend #.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) -- --containerized---well-known-frontend #.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 .PHONY: --frontend-dependencies --frontend-dependencies: node_modules package.json package-lock.json assets node_modules: package.json package-lock.json npm ci --cache .npm --prefer-offline package-lock.json: package.json npm install --cache .npm --prefer-offline 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 npx webpack --progress 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 --containerized-%-dev-backend; .PHONY: %-prod-backend %-prod-backend: FRADRIVE_SERVICE=backend %-prod-backend: --image-build --containerized-%-prod-backend; .PHONY: --%-dev-backend --%-dev-backend: FRADRIVE_SERVICE=backend --%-dev-backend: stackopts=--flag uniworx:dev --%-dev-backend: --image-build --containerized-%-backend; .PHONY: --%-prod-backend --%-prod-backend: FRADRIVE_SERVICE=backend --%-prod-backend: stackopts=--flag uniworx:-dev --%-prod-backend: --image-build --containerized-%-backend; .PHONY: serve-backend serve-backend: export DEV_PORT_HTTP=`netstat -tulan | perl -le 'use strict;use warnings;my %p=();my $addr=qr((?:\d+.\d+.\d+.\d+|[0-9a-f:]+));while(<>){ if(m#$addr:(\d+)\s+$addr:(?:\d+|\*)\s+#) { $p{$1}=1 }}; my $port = 3000; $port++ while $p{$port}; print $port'` ; \ export DEV_PORT_HTTPS=`netstat -tulan | perl -le 'use strict;use warnings;my %p=();my $addr=qr((?:\d+.\d+.\d+.\d+|[0-9a-f:]+));while(<>){ if(m#$addr:(\d+)\s+$addr:(?:\d+|\*)\s+#) { $p{$1}=1 }}; my $port = 3443; $port++ while $p{$port}; print $port'` ; \ echo "bisschen mehr: ${DEV_PORT_HTTP}" ; \ $(MAKE) -- --containerized---serve-dev-backend DEV_PORT_HTTP=${DEV_PORT_HTTP} DEV_PORT_HTTPS=${DEV_PORT_HTTPS} .PHONY: --serve-dev-backend --serve-dev-backend: ./start.sh .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: serve-database serve-database: --containerized-database .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-database --containerized-database: FRADRIVE_SERVICE=database --containerized-database: --image-build if [ "$(IN_CONTAINER)" == "false" ] ; then \ $(CONTAINER_COMMAND) run fradrive/$(FRADRIVE_SERVICE) ; \ fi .PHONY: --containerized-%-frontend --containerized-%-frontend: FRADRIVE_SERVICE=frontend #--containerized-%-frontend: --image-build --image-run-%-frontend; --containerized-%-frontend: --image-build if [ "$(IN_CONTAINER)" == "false" ] ; then \ $(MAKE) -- --image-run-$*-frontend ; \ fi .PHONY: --containerized-%-backend --containerized-%-backend: FRADRIVE_SERVICE=backend #--containerized-%-backend: --image-build --image-run-%-backend; --containerized-%-backend: --image-build if [ "$(IN_CONTAINER)" == "false" ] ; then \ $(MAKE) -- --image-run-$*-backend ; \ fi .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; \ if [ "$(IN_CONTAINER)" == "false" ] ; then \ $(CONTAINER_COMMAND) build $(NO_CACHE) -v $(PWD):$${MOUNT_DIR} --env IN_CONTAINER=true --build-arg MOUNT_DIR=$${MOUNT_DIR} --build-arg PROJECT_DIR=$${PROJECT_DIR} --tag fradrive/$(FRADRIVE_SERVICE) --file $(PWD)/.Dockerfile ; \ fi .PHONY: --image-run-% --image-run-%: ifeq ($(IN_CONTAINER),true) $(MAKE) -- $* else $(CONTAINER_COMMAND) run -v $(PWD):/mnt/fradrive --env FRADRIVE_MAKE_TARGET=$* fradrive/$(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