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))
|
2019-03-05 22:35:03 +00:00
|
|
|
DOCKER_CMD := $(DOCKER_RUN_CURRENT_USER) --rm -t -v $(PWD):/app -w /app -e "ELM_HOME=/app" $(DOCKER_IMG)
|
2017-09-02 18:19:11 +00:00
|
|
|
# macOS requires mktemp template to be at the end of the filename.
|
|
|
|
TEMPFILE := $(shell mktemp ./elm-XXXXXXXXXX)
|
|
|
|
# --output flag for elm make must end in .js or .html.
|
|
|
|
TEMPFILE_JS := "$(TEMPFILE).js"
|
2018-11-08 17:46:04 +00:00
|
|
|
TEMPOPENAPI := $(shell mktemp -d ./openapi-XXXXXXXXXX)
|
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"; \
|
|
|
|
docker build -t $(DOCKER_IMG) ../. > /dev/null; \
|
|
|
|
fi; )
|
|
|
|
|
|
|
|
format: elm-env $(ELM_FILES)
|
|
|
|
@echo ">> format front-end code"
|
|
|
|
@$(DOCKER_CMD) elm-format --yes $(ELM_FILES)
|
|
|
|
|
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
|
|
|
|
@$(DOCKER_CMD) elm-test
|
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
|
|
|
|
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)
|
|
|
|
@$(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
|
|
|
|
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
|