install:
	npm install

develop:
	REACT_APP_TYPE=ott \
	REACT_APP_CLIENT=insports \
	npm start

clean:
	rm -rf build

build: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	npm run build

build-stage: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=preproduction \
	REACT_APP_CLIENT=insports \
	REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \
	npm run build

build-a: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-a \
	npm run build

build-b: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-b \
	npm run build

build-c: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-c \
	npm run build

build-d: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-d \
	npm run build

build-e: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-e \
	npm run build

build-f: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-f \
	npm run build

build-g: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-g \
	npm run build

build-h: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-h \
	npm run build

build-i: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=insports \
	REACT_APP_STAGE=test-i \
	npm run build

auth-build:
	rm -rf build_auth

	REACT_APP_TYPE=auth-service \
	REACT_APP_ENV=staging \
	REACT_APP_GOOGLE_CLIENT_ID=1022673777479-43mqb9lsqkpcr47umuvsoo0eemfpljf5.apps.googleusercontent.com \
	BUILD_PATH=build_auth \
	GENERATE_SOURCEMAP=false \
	npx react-scripts build

	npx gzipper --verbose build_auth

auth-production-build:
	rm -rf build_auth

	REACT_APP_TYPE=auth-service \
	REACT_APP_ENV=production \
	REACT_APP_GOOGLE_CLIENT_ID=1022673777479-43mqb9lsqkpcr47umuvsoo0eemfpljf5.apps.googleusercontent.com \
	BUILD_PATH=build_auth \
	GENERATE_SOURCEMAP=false \
	npx react-scripts build

	npx gzipper --verbose build_auth

facr-build: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=facr \
	npm run build

lff-build: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=staging \
	REACT_APP_CLIENT=lff \
	npm run build

.PHONY: build

prod: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=production \
	REACT_APP_CLIENT=insports \
	REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \
	npm run build && cp -r .well-known build

# 	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@de.instat.tv:/usr/local/www/ott/wwwroot/
# 	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@fr.instat.tv:/usr/local/www/ott/wwwroot/
# 	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@137.74.33.74:/usr/local/www/ott/wwwroot/

preprod: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=preproduction \
	REACT_APP_STAGE=test \
	REACT_APP_CLIENT=insports \
	REACT_APP_STRIPE_PK=pk_live_ANI76cBhSo69DZUxPmyRVIZW \
	npm run build

facr-prod: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=production \
	REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \
	REACT_APP_CLIENT=facr \
	npm run build

	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@de.instat.tv:/usr/local/www/ott/facr-wwwroot/
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@fr.instat.tv:/usr/local/www/ott/facr-wwwroot/
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@137.74.33.74:/usr/local/www/ott/facr-wwwroot/

lff-prod: clean
	REACT_APP_TYPE=ott \
	REACT_APP_ENV=production \
	REACT_APP_STRIPE_PK=pk_live_51J5TEYEDSxVnTgDW7v2lF8GGogrm7XaaICZ9CN876sITIBBauZgB2ommUTUOiY868jzpbhQjZcoBOjIRX5Vs54Aq00y4C3USyB \
	REACT_APP_CLIENT=lff \
	npm run build

	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@de.instat.tv:/usr/local/www/ott/lff-wwwroot/
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@fr.instat.tv:/usr/local/www/ott/lff-wwwroot/
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott@137.74.33.74:/usr/local/www/ott/lff-wwwroot/

deploy-all: prod preprod facr-prod lff-prod

stage: build-stage
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/wwwroot/

a-stage: build-a
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/a-wwwroot/

b-stage: build-b
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/b-wwwroot/

c-stage: build-c
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/c-wwwroot/

d-stage: build-d
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/d-wwwroot/

e-stage: build-e
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/e-wwwroot/

f-stage: build-f
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/f-wwwroot/

g-stage: build-g
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/g-wwwroot/

h-stage: build-h
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/h-wwwroot/

i-stage: build-i
	rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@137.74.33.74:/usr/local/www/ott-staging/i-wwwroot/

test:
	npm test

.PHONY: test
