forked from internetarchive/openlibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (70 loc) · 3.23 KB
/
Makefile
File metadata and controls
88 lines (70 loc) · 3.23 KB
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
#
# 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
OSP_DUMP_LOCATION=/solr-updater-data/osp_totals.db
.PHONY: all clean distclean git css js components lit-components i18n lint
all: git css js components lit-components i18n
css:
node scripts/generate-css-custom-properties.js
mkdir -p $(BUILD)/css_new
BUILD_DIR=$(BUILD)/css_new NODE_ENV=production npx webpack --config webpack.config.css.js
mkdir -p $(BUILD)/css
rm -rf $(BUILD)/css
mv $(BUILD)/css_new $(BUILD)/css
js:
mkdir -p $(BUILD)/js_new
BUILD_DIR=$(BUILD)/js_new NODE_ENV=production npx webpack
# This adds FSF licensing for AGPLv3 to our js (for librejs)
for js in $(BUILD)/js_new/*.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
mkdir -p $(BUILD)/js
rm -rf $(BUILD)/js
mv $(BUILD)/js_new $(BUILD)/js
components:
mkdir -p $(BUILD)/components_new
BUILD_DIR=$(BUILD)/components_new npx vite build -c openlibrary/components/vite.config.mjs
mkdir -p $(BUILD)/components
rm -rf $(BUILD)/components
mv $(BUILD)/components_new $(BUILD)/components
lit-components:
mkdir -p $(BUILD)/lit-components_new
BUILD_DIR=$(BUILD)/lit-components_new NODE_ENV=production npx vite build -c openlibrary/components/vite-lit.config.mjs
mkdir -p $(BUILD)/lit-components
rm -rf $(BUILD)/lit-components
mv $(BUILD)/lit-components_new $(BUILD)/lit-components
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
reindex-solr:
# Keep link in sync with ol-solr-updater-start and Jenkinsfile
curl -L "https://archive.org/download/2023_openlibrary_osp_counts/osp_totals.db" -o $(OSP_DUMP_LOCATION)
psql --host db openlibrary -t -c 'select key from thing' | sed 's/ *//' | grep '^/books/' | PYTHONPATH=$(PWD) xargs python openlibrary/solr/update.py --ol-url http://web:8080/ --osp-dump $(OSP_DUMP_LOCATION) --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.py --ol-url http://web:8080/ --osp-dump $(OSP_DUMP_LOCATION) --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 pyproject.toml file for ruff's settings
python -m ruff check .
test-py:
pytest . --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 it ja zh
test:
make test-py && npm run test && make test-i18n