npm-build:
	npm run build

npm-watch:
	npm run watch

.ONESHELL:
release: npm-build translations
	if [ -z "$$VERSION" ]; then
		echo "VERSION required"
		exit 1
	fi

	if [ -z "$$RELEASE_DIRECTORY" ]; then
		RELEASE_DIRECTORY=releases
	fi

	test -d $$RELEASE_DIRECTORY/$$VERSION && rm -fr $$RELEASE_DIRECTORY/$$VERSION
	mkdir -p $$RELEASE_DIRECTORY/$$VERSION/side_menu
	cp -r README.md CHANGELOG.md appinfo css lib img l10n js src templates screenshots vendor $$RELEASE_DIRECTORY/$$VERSION/side_menu
	cd $$RELEASE_DIRECTORY/$$VERSION
	zip -r side_menu_v$$VERSION.zip side_menu
	tar cvzf side_menu_v$$VERSION.tar.gz side_menu
	rm -fr side_menu
	openssl dgst -sha512 -sign $$HOME/.nextcloud/certificates/side_menu.key side_menu_v$$VERSION.tar.gz | openssl base64 > side_menu_v$$VERSION.sig

translations:
	php bin/generate_l10n.php
