#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/pkg-info.mk
DEB_VERSION_TRIM=$(word 1,$(subst +, ,$(DEB_VERSION)))

%:
	dh $@

execute_before_dh_auto_configure:
	rsync -a microsoft-fast-web-utilities/packages/utilities/fast-web-utilities/ fast-web-utilities
	rsync -a microsoft-fast-colors/packages/utilities/fast-colors/ fast-colors
	rsync -a microsoft-fast-element/packages/web-components/fast-element/ fast-element
	rsync -a microsoft-fast-foundation/packages/web-components/fast-foundation/ fast-foundation
	rsync -a microsoft-fast-router/packages/web-components/fast-router/ fast-router
	rsync -a microsoft-fast-react-wrapper/packages/utilities/fast-react-wrapper/ fast-react-wrapper


execute_before_dh_clean:
	rm -rf fast-web-utilities
	rm -rf fast-element
	rm -rf fast-foundation
	rm -rf fast-router
	rm -rf fast-react-wrapper
	rm -rf fast-colors

#override_dh_auto_build:
#	ALIASES="api-extractor,/usr/bin/true babel,/usr/bin/babeljs" pkgjs-lerna run build

execute_after_dh_installdocs:
	dh_nodejs_autodocs auto_dispatch

execute_after_dh_auto_install:
	find debian/tmp -name .eslintrc.js -delete
	find debian/tmp -name 'karma.conf.*[jt]s' -delete
	find debian/tmp -name CHANGELOG.json -delete
	find debian/tmp -name 'tsconfig*.json' -delete
	find debian/tmp -name 'tslint.json' -delete
	find debian/tmp -name 'tsdoc.json' -delete
	find debian/tmp -name 'api-extractor.json' -delete
	rm -rf debian/tmp/usr/share/nodejs/@microsoft/fast
	rm -rf tmp/usr/share/nodejs/@microsoft/fast-colors/testData.ts

override_dh_gencontrol:
	set -e;for c in `pkgjs-utils root_components_list 2>/dev/null | grep -v types-web-ie11`; do \
		NAME=`pkgjs-pjson $$c name`; \
		VERSION=`pkgjs-pjson $$c version|sed -e 's/-/~/g'`; \
		PKG=node-`pkgjs-utils normalize_name $$NAME`; \
		case $$PKG in \
		node-microsoft-fast-element) \
			VERSION='2.0.0+really'$$VERSION \
			;; \
		node-microsoft-foundation) \
			VERSION='3.0.0+really'$$VERSION \
			;; \
		node-microsoft-fast-react-wrapper) \
			VERSION='1.0.0+really'$$VERSION \
			;; \
		node-microsoft-fast-router) \
			VERSION='1.0.0+really'$$VERSION \
			;; \
		inode-microsoft-fast-web-utilities) \
			VERSION='6.0.0+really'$$VERSION \
			;; \
		esac; \
		dh_gencontrol -p$$PKG -- -v$${VERSION}~$(DEB_VERSION_TRIM) ;\
	done
