<commit_before>##################
# Install commands
##################
install-python:
	pip install -r requirements/django.txt
	pip install -r requirements/base.txt --only-binary=lxml,libsass

install-js:
	npm install

install-test:
	pip install -r requirements/test.txt

install: install-python install-js install-test javascript sass

##############################
# Generate js/css output files
##############################
STATIC_JS = openassessment/xblock/static/js
STATIC_CSS = openassessment/xblock/static/css

update-npm-requirements:
	npm update --silent
	cp ./node_modules/backgrid/lib/backgrid*.js $(STATIC_JS)/lib/backgrid/
	cp ./node_modules/backgrid/lib/backgrid*.css $(STATIC_CSS)/lib/backgrid/

javascript: update-npm-requirements
	node_modules/.bin/uglifyjs $(STATIC_JS)/src/oa_shared.js $(STATIC_JS)/src/*.js $(STATIC_JS)/src/lms/*.js $(STATIC_JS)/lib/backgrid/backgrid.min.js -c warnings=false > "$(STATIC_JS)/openassessment-lms.min.js"
	node_modules/.bin/uglifyjs $(STATIC_JS)/src/oa_shared.js $(STATIC_JS)/src/*.js $(STATIC_JS)/src/studio/*.js $(STATIC_JS)/lib/backgrid/backgrid.min.js -c warnings=false > "$(STATIC_JS)/openassessment-studio.min.js"

sass:
	python scripts/compile_sass.py

verify-generated-files:
	@git diff --quiet || (echo 'Modifications exist locally! Run `make javascript` or `make sass` to update bundled files.'; exit 1)

################
#Translations Handling
################    
# creates the django-partial.po & django-partial.mo files
extract_translations:
	i18n_tool extract -v

# compiles the *.po & *.mo files
compile_translations:
	cd ./openassessment/ && i18n_tool generate -v && cd ..

# generate dummy translations
generate_dummy_translations:
	i18n_tool dummy

# check if translation files are up-to-date
detect_changed_source_translations:
	i18n_tool changed

# extract, compile, and check if translation files are up-to-date
validate_translations: extract_translations compile_translations generate_dummy_translations detect_changed_source_translations

################
#Tests and checks
################
quality:
	./node_modules/.bin/jshint $(STATIC_JS)/src -c .jshintrc --verbose
	./node_modules/jscs/bin/jscs $(STATIC_JS)/src --verbose<commit_msg>Add Transifex make pull command<commit_after>##################
# Install commands
##################
install-python:
	pip install -r requirements/django.txt
	pip install -r requirements/base.txt --only-binary=lxml,libsass

install-js:
	npm install

install-test:
	pip install -r requirements/test.txt

install: install-python install-js install-test javascript sass

##############################
# Generate js/css output files
##############################
STATIC_JS = openassessment/xblock/static/js
STATIC_CSS = openassessment/xblock/static/css

update-npm-requirements:
	npm update --silent
	cp ./node_modules/backgrid/lib/backgrid*.js $(STATIC_JS)/lib/backgrid/
	cp ./node_modules/backgrid/lib/backgrid*.css $(STATIC_CSS)/lib/backgrid/

javascript: update-npm-requirements
	node_modules/.bin/uglifyjs $(STATIC_JS)/src/oa_shared.js $(STATIC_JS)/src/*.js $(STATIC_JS)/src/lms/*.js $(STATIC_JS)/lib/backgrid/backgrid.min.js -c warnings=false > "$(STATIC_JS)/openassessment-lms.min.js"
	node_modules/.bin/uglifyjs $(STATIC_JS)/src/oa_shared.js $(STATIC_JS)/src/*.js $(STATIC_JS)/src/studio/*.js $(STATIC_JS)/lib/backgrid/backgrid.min.js -c warnings=false > "$(STATIC_JS)/openassessment-studio.min.js"

sass:
	python scripts/compile_sass.py

verify-generated-files:
	@git diff --quiet || (echo 'Modifications exist locally! Run `make javascript` or `make sass` to update bundled files.'; exit 1)

################
#Translations Handling
################    
# creates the django-partial.po & django-partial.mo files
extract_translations:
	i18n_tool extract -v

# compiles the *.po & *.mo files
compile_translations:
	cd ./openassessment/ && i18n_tool generate -v && cd ..

# generate dummy translations
generate_dummy_translations:
	i18n_tool dummy

# check if translation files are up-to-date
detect_changed_source_translations:
	i18n_tool changed

# pull translations from Transifex
pull_translations: 
	cd ./openassessment/ && tx pull -af --mode reviewed

# extract, compile, and check if translation files are up-to-date
validate_translations: extract_translations compile_translations generate_dummy_translations detect_changed_source_translations

################
#Tests and checks
################
quality:
	./node_modules/.bin/jshint $(STATIC_JS)/src -c .jshintrc --verbose
	./node_modules/jscs/bin/jscs $(STATIC_JS)/src --verbose
{'fraction_non_alphanumeric': 0.1803818301514154, 'fraction_numerical': 0.003949967083607637, 'mean_word_length': 5.348189415041783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6823957', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1433, 'n_words': 315}