2018-11-08 17:46:04 +00:00
|
|
|
# Use `=` instead of `:=` expanding variable lazely, not at beginning. Needed as
|
|
|
|
# elm files change during execution.
|
|
|
|
ELM_FILES = $(shell find src -iname *.elm)
|
2018-09-06 16:08:51 +00:00
|
|
|
DOCKER_IMG := elm-env
|
2019-03-05 17:57:07 +00:00
|
|
|
DOCKER_RUN_CURRENT_USER := docker run --user=$(shell id -u $(USER)):$(shell id -g $(USER))
|
2021-04-27 05:14:00 +00:00
|
|
|
DOCKER_CMD := $(DOCKER_RUN_CURRENT_USER) --rm -t -v $(PWD):/app -w /app -e "ELM_HOME=/app/.elm" $(DOCKER_IMG)
|
2020-06-04 07:49:32 +00:00
|
|
|
# If JUNIT_DIR is set, the tests are executed with the JUnit reporter and the result is stored in the given directory.
|
|
|
|
JUNIT_DIR ?=
|
2017-04-21 16:42:29 +00:00
|
|
|
|
2017-05-12 14:49:32 +00:00
|
|
|
ifeq ($(NO_DOCKER), true)
|
|
|
|
DOCKER_CMD=
|
|
|
|
endif
|
|
|
|
|
2018-11-08 17:46:04 +00:00
|
|
|
all: script.js test
|
2017-05-12 14:49:32 +00:00
|
|
|
|
|
|
|
elm-env:
|
|
|
|
@(if [ "$(NO_DOCKER)" != "true" ] ; then \
|
|
|
|
echo ">> building elm-env docker image"; \
|
2024-04-25 16:39:05 +00:00
|
|
|
docker build --platform=linux/amd64 -t $(DOCKER_IMG) ../. > /dev/null; \
|
2017-05-12 14:49:32 +00:00
|
|
|
fi; )
|
|
|
|
|
|
|
|
format: elm-env $(ELM_FILES)
|
|
|
|
@echo ">> format front-end code"
|
|
|
|
@$(DOCKER_CMD) elm-format --yes $(ELM_FILES)
|
|
|
|
|
2021-04-27 05:14:00 +00:00
|
|
|
review: src/Data elm-env
|
|
|
|
@$(DOCKER_CMD) elm-review --fix
|
|
|
|
|
2018-11-08 17:46:04 +00:00
|
|
|
test: src/Data elm-env
|
2018-09-06 16:08:51 +00:00
|
|
|
@$(DOCKER_CMD) rm -rf elm-stuff/generated-code
|
2017-05-12 14:49:32 +00:00
|
|
|
@$(DOCKER_CMD) elm-format $(ELM_FILES) --validate
|
2021-04-27 05:14:00 +00:00
|
|
|
@$(DOCKER_CMD) elm-review
|
2020-06-04 07:49:32 +00:00
|
|
|
ifneq ($(JUNIT_DIR),)
|
|
|
|
mkdir -p $(JUNIT_DIR)
|
|
|
|
@$(DOCKER_CMD) elm-test --report=junit | tee $(JUNIT_DIR)/junit.xml
|
|
|
|
else
|
2017-05-12 14:49:32 +00:00
|
|
|
@$(DOCKER_CMD) elm-test
|
2020-06-04 07:49:32 +00:00
|
|
|
endif
|
2017-04-21 16:42:29 +00:00
|
|
|
|
|
|
|
dev-server:
|
2018-09-06 16:08:51 +00:00
|
|
|
elm reactor
|
2017-06-07 20:38:39 +00:00
|
|
|
|
2021-04-27 05:14:00 +00:00
|
|
|
# macOS requires mktemp template to be at the end of the filename,
|
|
|
|
# however --output flag for elm make must end in .js or .html.
|
|
|
|
script.js: export TEMPFILE := "$(shell mktemp ./elm-XXXXXXXXXX)"
|
|
|
|
script.js: export TEMPFILE_JS := "$(TEMPFILE).js"
|
2018-11-08 17:46:04 +00:00
|
|
|
script.js: src/Data elm-env format $(ELM_FILES)
|
2017-05-12 14:49:32 +00:00
|
|
|
@echo ">> building script.js"
|
2018-09-06 16:08:51 +00:00
|
|
|
@$(DOCKER_CMD) rm -rf elm-stuff
|
|
|
|
@$(DOCKER_CMD) elm make src/Main.elm --optimize --output $(TEMPFILE_JS)
|
2021-04-27 05:14:00 +00:00
|
|
|
@$(DOCKER_CMD) uglifyjs $(TEMPFILE_JS) --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' --mangle --output $(@)
|
2018-03-20 10:54:44 +00:00
|
|
|
@rm -rf $(TEMPFILE_JS)
|
|
|
|
@rm -rf $(TEMPFILE)
|
2017-05-12 14:49:32 +00:00
|
|
|
|
2021-04-27 05:14:00 +00:00
|
|
|
src/Data: export TEMPOPENAPI := $(shell mktemp -d ./openapi-XXXXXXXXXX)
|
2018-11-08 17:46:04 +00:00
|
|
|
src/Data: ../../api/v2/openapi.yaml
|
|
|
|
-rm -r src/Data
|
2019-03-05 17:57:07 +00:00
|
|
|
$(DOCKER_RUN_CURRENT_USER) --rm -v ${PWD}/../..:/local openapitools/openapi-generator-cli:v3.3.4 generate \
|
2018-11-28 12:08:48 +00:00
|
|
|
-i /local/api/v2/openapi.yaml \
|
|
|
|
-g elm \
|
2018-11-08 17:46:04 +00:00
|
|
|
-o /local/ui/app/$(TEMPOPENAPI)
|
|
|
|
# We only want data directory & DateTime package.
|
|
|
|
cp -r $(TEMPOPENAPI)/src/Data src/Data
|
|
|
|
cp -r $(TEMPOPENAPI)/src/DateTime.elm src/DateTime.elm
|
|
|
|
rm -rf $(TEMPOPENAPI)
|
|
|
|
|
|
|
|
|
2017-05-12 14:49:32 +00:00
|
|
|
clean:
|
2019-11-20 09:45:46 +00:00
|
|
|
- @rm -rf script.js elm-stuff src/Data src/DateTime.elm openapi-* elm-*
|
2019-03-05 17:57:07 +00:00
|
|
|
- @if [ ! -z "$(docker images -q $(DOCKER_IMG))" ]; then \
|
|
|
|
docker rmi $(DOCKER_IMG); fi
|