PHONY:= release# debug clean prepare node_modules
PLUGINS_PATH?=./plugins
PLUGINS_DIR:=$(wildcard ${PLUGINS_PATH}/*)
empty:=
comma:=,
space:= $(empty) $(empty)
PLUGINS=$(subst $(space),$(comma),$(PLUGINS_DIR))
CORE_DIR?=./core/sulu

all: release

node_modules: package.json
	yarn install --frozen-lockfile > /dev/null 2>&1

update:
	./scripts/update.sh update

commit:
	@./scripts/update.sh commit

dev: node_modules
	@echo -e "\033[0;33mRun \033[0;31m[cd build && yarn && yarn dev]\033[0m \033[0;33min a separate shell\033[0m"
	yarn build -vopt --suluDir ${CORE_DIR} --pluginPaths=${PLUGINS} --writeDir=./build  --version=somehash1.11

release: node_modules
ifneq ($(VERSION),)
	yarn build -vo --suluDir ${CORE_DIR} --pluginPaths=${PLUGINS} --version=${VERSION} --writeDir=./build
else
	yarn build -vo --suluDir ${CORE_DIR} --pluginPaths=${PLUGINS} --writeDir=./build
endif
	cd build && make

pull: modules.mk
	./scripts/update.sh pull

tar:
	./scripts/update.sh tar

.PHONY: $(PHONY)

clean:
	@echo "===== CLEAN ====="
	rm -rf build node_modules

distclean:
	@echo "===== CLEAN ====="
	rm -rf build node_modules plugins core
