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
2017-05-12 14:49:32 +00:00
DOCKER_CMD := docker run --rm -t -v $( PWD) :/app -w /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
i f e q ( $( NO_DOCKER ) , t r u e )
DOCKER_CMD =
e n d i f
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 /v 2/openapi .yaml
-rm -r src/Data
2018-11-28 12:08:48 +00:00
# TODO: Use released version instead of `@sha256:d9f87079bb4d7[...]` that
# includes patch for
# https://github.com/OpenAPITools/openapi-generator/issues/1465
docker run --user= $( shell id -u $( USER) ) :$( shell id -g $( USER) ) --rm -v ${ PWD } /../..:/local openapitools/openapi-generator-cli@sha256:d9f87079bb4d769e2c6f2a6b72677f4d5e64db687db0455eb41227663290e53c generate \
-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 :
- @rm script.js
2018-09-06 16:08:51 +00:00
- @rm -rf elm-stuff
2018-11-08 17:46:04 +00:00
- @rm -rf src/Data
- @rm -f src/DateTime.elm
2017-05-12 14:49:32 +00:00
- @docker rmi $( DOCKER_IMG)
2018-11-08 17:46:04 +00:00
- rm -r openapi-*