<commit_before>STYLE_TARGETS=actions assets commands components controllers models
JS_SRCS=$(shell ls -1 resources/stat.ink/main.js/*.js)
COMPOSER_VERSION=1.0.0-alpha11
GULP=./node_modules/.bin/gulp

RESOURCE_TARGETS_MAIN=\
	resources/.compiled/activity/activity.js \
	resources/.compiled/flot-graph-icon/jquery.flot.icon.js \
	resources/.compiled/gears/calc.js \
	resources/.compiled/gh-fork-ribbon/gh-fork-ribbon.css \
	resources/.compiled/gh-fork-ribbon/gh-fork-ribbon.js \
	resources/.compiled/stat.ink/favicon.png \
	resources/.compiled/stat.ink/main.css \
	resources/.compiled/stat.ink/main.js \
	resources/.compiled/stat.ink/no-image.png

RESOURCE_TARGETS=\
	$(RESOURCE_TARGETS_MAIN) \
	$(RESOURCE_TARGETS_MAIN:.css=.css.br) \
	$(RESOURCE_TARGETS_MAIN:.css=.css.gz) \
	$(RESOURCE_TARGETS_MAIN:.js=.js.br) \
	$(RESOURCE_TARGETS_MAIN:.js=.js.gz) \

all: init migrate-db

init: \
	composer.phar \
	composer-plugin \
	vendor \
	vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php \
	node_modules \
	config/debug-ips.php \
	config/google-analytics.php \
	config/google-recaptcha.php \
	config/google-adsense.php \
	config/amazon-s3.php \
	config/backup-s3.php \
	config/cookie-secret.php \
	config/backup-gpg.php \
	config/db.php \
	resource

docker: all
	sudo docker build -t jp3cki/statink .

ikalog: all runtime/ikalog runtime/ikalog/repo runtime/ikalog/winikalog.html
	cd runtime/ikalog/repo && git fetch --all --prune && git rebase origin/master
	./yii ikalog/update-ikalog
	./yii ikalog/update-winikalog

resource: $(RESOURCE_TARGETS)

composer-plugin: composer.phar
	grep '"fxp/composer-asset-plugin"' ~/.composer/composer.json >/dev/null || ./composer.phar global require 'fxp/composer-asset-plugin:^1.1'
	grep '"hirak/prestissimo"' ~/.composer/composer.json >/dev/null || ./composer.phar global require 'hirak/prestissimo:^0.1'

vendor: composer.phar composer.lock
	php composer.phar install --prefer-dist --profile
	touch -r composer.lock vendor

node_modules: package.json
	npm install

check-style: vendor
	vendor/bin/phpcs --standard=PSR2 --encoding=UTF-8 --runtime-set ignore_warnings_on_exit 1 $(STYLE_TARGETS)
	vendor/bin/check-author.php --php-files $(STYLE_TARGETS)

fix-style: vendor
	vendor/bin/phpcbf --standard=PSR2 --encoding=UTF-8 $(STYLE_TARGETS)

clean: clean-resource
	rm -rf \
		composer.phar \
		node_modules \
		runtime/ikalog \
		vendor

clean-resource:
	rm -rf \
		resources/.compiled/* \
		web/assets/*

composer.phar:
	curl -sS https://getcomposer.org/installer | php -- --version=$(COMPOSER_VERSION)

%.br: %.gz
	rm -f $@
	zcat $< | bro --quality 11 --output $@

%.css.gz: %.css
	gzip -9c $< > $@

%.js.gz: %.js
	gzip -9c $< > $@

$(GULP): node_modules
	touch $(GULP)

resources/.compiled/stat.ink/main.js: $(JS_SRCS) $(GULP)
	$(GULP) js --in 'resources/stat.ink/main.js/*.js' --out $@

resources/.compiled/stat.ink/main.css: resources/stat.ink/main.less $(GULP)
	$(GULP) less --in $< --out $@

resources/.compiled/gh-fork-ribbon/gh-fork-ribbon.js: resources/gh-fork-ribbon/gh-fork-ribbon.js $(GULP)<commit_msg>update composer.lock automatically if needed<commit_after>STYLE_TARGETS=actions assets commands components controllers models
JS_SRCS=$(shell ls -1 resources/stat.ink/main.js/*.js)
COMPOSER_VERSION=1.0.0-alpha11
GULP=./node_modules/.bin/gulp

RESOURCE_TARGETS_MAIN=\
	resources/.compiled/activity/activity.js \
	resources/.compiled/flot-graph-icon/jquery.flot.icon.js \
	resources/.compiled/gears/calc.js \
	resources/.compiled/gh-fork-ribbon/gh-fork-ribbon.css \
	resources/.compiled/gh-fork-ribbon/gh-fork-ribbon.js \
	resources/.compiled/stat.ink/favicon.png \
	resources/.compiled/stat.ink/main.css \
	resources/.compiled/stat.ink/main.js \
	resources/.compiled/stat.ink/no-image.png

RESOURCE_TARGETS=\
	$(RESOURCE_TARGETS_MAIN) \
	$(RESOURCE_TARGETS_MAIN:.css=.css.br) \
	$(RESOURCE_TARGETS_MAIN:.css=.css.gz) \
	$(RESOURCE_TARGETS_MAIN:.js=.js.br) \
	$(RESOURCE_TARGETS_MAIN:.js=.js.gz) \

all: init migrate-db

init: \
	composer.phar \
	composer-plugin \
	vendor \
	vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php \
	node_modules \
	config/debug-ips.php \
	config/google-analytics.php \
	config/google-recaptcha.php \
	config/google-adsense.php \
	config/amazon-s3.php \
	config/backup-s3.php \
	config/cookie-secret.php \
	config/backup-gpg.php \
	config/db.php \
	resource

docker: all
	sudo docker build -t jp3cki/statink .

ikalog: all runtime/ikalog runtime/ikalog/repo runtime/ikalog/winikalog.html
	cd runtime/ikalog/repo && git fetch --all --prune && git rebase origin/master
	./yii ikalog/update-ikalog
	./yii ikalog/update-winikalog

resource: $(RESOURCE_TARGETS)

composer-plugin: composer.phar
	grep '"fxp/composer-asset-plugin"' ~/.composer/composer.json >/dev/null || ./composer.phar global require 'fxp/composer-asset-plugin:^1.1'
	grep '"hirak/prestissimo"' ~/.composer/composer.json >/dev/null || ./composer.phar global require 'hirak/prestissimo:^0.1'

vendor: composer.phar composer.lock
	php composer.phar install --prefer-dist --profile
	touch -r composer.lock vendor

node_modules: package.json
	npm install

check-style: vendor
	vendor/bin/phpcs --standard=PSR2 --encoding=UTF-8 --runtime-set ignore_warnings_on_exit 1 $(STYLE_TARGETS)
	vendor/bin/check-author.php --php-files $(STYLE_TARGETS)

fix-style: vendor
	vendor/bin/phpcbf --standard=PSR2 --encoding=UTF-8 $(STYLE_TARGETS)

clean: clean-resource
	rm -rf \
		composer.phar \
		node_modules \
		runtime/ikalog \
		vendor

clean-resource:
	rm -rf \
		resources/.compiled/* \
		web/assets/*

composer.phar:
	curl -sS https://getcomposer.org/installer | php -- --version=$(COMPOSER_VERSION)

composer.lock: composer.json composer.phar
	./composer.phar update -vvv

%.br: %.gz
	rm -f $@
	zcat $< | bro --quality 11 --output $@

%.css.gz: %.css
	gzip -9c $< > $@

%.js.gz: %.js
	gzip -9c $< > $@

$(GULP): node_modules
	touch $(GULP)

resources/.compiled/stat.ink/main.js: $(JS_SRCS) $(GULP)
	$(GULP) js --in 'resources/stat.ink/main.js/*.js' --out $@

resources/.compiled/stat.ink/main.css: resources/stat.ink/main.less $(GULP)
	$(GULP) less --in $< --out $@

resources/.compiled/gh-fork-ribbon/gh-fork-ribbon.js: resources/gh-fork-ribbon/gh-fork-ribbon.js $(GULP)
{'fraction_non_alphanumeric': 0.16042866282789509, 'fraction_numerical': 0.007037747920665387, 'mean_word_length': 3.6979714500375658, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1472904', 'n_tokens_mistral': 2541, 'n_tokens_neox': 2405, 'n_words': 377}