forked from internetarchive/openlibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (62 loc) · 2.92 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
#
# Makefile to build css and js files, compile i18n messages and stamp
# version information
#
BUILD=static/build
ACCESS_LOG_FORMAT='%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s"'
COMPONENTS_DIR=openlibrary/components
# Use python from local env if it exists or else default to python in the path.
PYTHON=$(if $(wildcard env),env/bin/python,python)
.PHONY: all clean distclean git css js components i18n lint
all: git css js components i18n
css: static/css/page-*.less
mkdir -p $(BUILD)
parallel --verbose -q npx lessc {} $(BUILD)/{/.}.css --clean-css="--s1 --advanced" ::: $^
js:
mkdir -p $(BUILD)
rm -f $(BUILD)/*.js $(BUILD)/*.js.map
npm run build-assets:webpack
# This adds FSF licensing for AGPLv3 to our js (for librejs)
for js in $(BUILD)/*.js; do \
echo "// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3.0" | cat - $$js > /tmp/js && mv /tmp/js $$js; \
echo "\n// @license-end" >> $$js; \
done
components: $(COMPONENTS_DIR)/*.vue
mkdir -p $(BUILD)
rm -rf $(BUILD)/components
# Run these silly things one at a time, because they don't support parallelization :(
parallel --verbose -q --jobs 1 \
npx vue-cli-service build --no-clean --mode production --dest $(BUILD)/components/production --target wc --name "ol-{/.}" "{}" \
::: $^
i18n:
$(PYTHON) ./scripts/i18n-messages compile
git:
git submodule init
git submodule sync
git submodule update
clean:
rm -rf $(BUILD)
distclean:
git clean -fdx
git submodule foreach git clean -fdx
load_sample_data:
@echo "loading sample docs from openlibrary.org website"
$(PYTHON) scripts/copydocs.py --list /people/anand/lists/OL1815L
curl http://localhost:8080/_dev/process_ebooks # hack to show books in returncart
reindex-solr:
psql --host db openlibrary -t -c 'select key from thing' | sed 's/ *//' | grep '^/books/' | PYTHONPATH=$(PWD) xargs python openlibrary/solr/update_work.py --ol-url http://web:8080/ --ol-config conf/openlibrary.yml --data-provider=legacy --solr-next
psql --host db openlibrary -t -c 'select key from thing' | sed 's/ *//' | grep '^/authors/' | PYTHONPATH=$(PWD) xargs python openlibrary/solr/update_work.py --ol-url http://web:8080/ --ol-config conf/openlibrary.yml --data-provider=legacy --solr-next
PYTHONPATH=$(PWD) python ./scripts/solr_builder/solr_builder/index_subjects.py subject
PYTHONPATH=$(PWD) python ./scripts/solr_builder/solr_builder/index_subjects.py person
PYTHONPATH=$(PWD) python ./scripts/solr_builder/solr_builder/index_subjects.py place
PYTHONPATH=$(PWD) python ./scripts/solr_builder/solr_builder/index_subjects.py time
lint:
# See the file .flake8 for flake8's settings
$(PYTHON) -m flake8 .
test-py:
pytest . --ignore=tests/integration --ignore=infogami --ignore=vendor --ignore=node_modules
test-i18n:
# Valid locale codes should be added as arguments to validate
$(PYTHON) ./scripts/i18n-messages validate de es fr hr ja zh
test:
make test-py && npm run test && make test-i18n