-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
95 lines (76 loc) · 2.61 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
export PHP_CS_FIXER_IGNORE_ENV=1
SHELL=/bin/bash
PHP=$$(command -v php)
VINFO=https://www.pochta.ru/support/database/ops
PINDX_REGEX='(/assets[^"]+[iI]ndx_[^"]+.zip)'
.PHONY=all
all: docs/json docs/json/index.json
mkdir -p build/cache
$(PHP) vendor/bin/php-cs-fixer fix
git add docs/json/
.PHONY=check
check:
curl -I --silent --show-error --fail -o /dev/null $(VINFO)
# All clear!
ops.txt:
timeout -k 15 10 curl -o ops.txt $(VINFO)
echo -en $$(cat ops.txt) > ops.txt
echo -en $$(cat ops.txt) > ops.txt
grep -q Эталонный ops.txt
PIndx.zip: ops.txt
grep -Eo $(PINDX_REGEX) ops.txt
wget -O PIndx.zip "https://www.pochta.ru$$(cat ops.txt | grep -Eo $(PINDX_REGEX) | head -n1)"
unzip -t PIndx.zip
PIndx.dbf: PIndx.zip
unzip -p PIndx.zip > PIndx.dbf
PIndx.txt: PIndx.dbf
@$$(command -v dbview) --version
dbview -o -e -r PIndx.dbf > PIndx.txt || true
PIndx.tsv: PIndx.dbf
@$$(command -v dbview) --version
dbview PIndx.dbf | iconv -f CP866 | grep -q $$'\t' && echo "Found a tab character, cannot proceed with .tsv conversion" || true
dbview -t -b -d$$'\t' PIndx.dbf | iconv -f CP866 > PIndx.tsv
grep -q ^0 PIndx.tsv && echo "Found a postal code beginning with a zero" || true
docs/json: PIndx.tsv vendor/autoload.php
$(PHP) bin/JSONIndex.php
touch --no-create docs/json/
docs/json/index.json: PIndx.tsv vendor/autoload.php
$(PHP) bin/JSONListIndex.php
.PHONY=cs
cs:
$(PHP) vendor/bin/php-cs-fixer fix -v
.PHONY=clean
clean:
rm -fv PIndx.tsv PIndx.txt PIndx.dbf PIndx.zip ops.txt
git rm -qr docs/json/
.PHONY=cron-clean
cron-clean: clean
find composer.lock vendor/autoload.php -mtime +30 -delete
.PHONY=test
test: vendor/autoload.php
$(PHP) vendor/bin/phpunit
vendor/autoload.php: composer.lock
$(PHP) -v
composer install
composer.lock: composer.json
composer update
touch -r composer.lock composer.json
.PHONY=cron
cron: all version
.PHONY=version
version: ops.txt
# Downloading ...
elinks -version | head -n 1
cat ops.txt | \
grep -a -A1 .формирован | \
grep -a -oE [0-9]{2}\\.[0-9]{2}\\.[0-9]{4} | \
sed -E 's,([0-9]{2}).([0-9]{2}).([0-9]{4}),\3-\2-\1,g' | \
grep -o [0-9]*-[0-9]*-[0-9]* | head -n 1 > docs/_data/last-update-date
sed s/date-updated/$$(cat docs/_data/last-update-date)/ docs/_data/status.yml.template > docs/_data/status.yml
git add docs/_data/status.yml
cat docs/_data/last-update-date
.PHONY=commit
commit:
if ! git diff --cached --quiet; then git commit -m "Automatic build for $$(cat docs/_data/last-update-date)"; git push; fi
docs/_includes/default.html:
wget -O docs/_includes/default.html https://raw.githubusercontent.com/pages-themes/dinky/master/_layouts/default.html