blob: f4df6f630d827e7ec5cf141a40f88e44d829a9ce (
plain)
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
|
#!/usr/bin/env bash
COLOR_RED="\e[31m"
COLOR_GREEN="\e[32m"
COLOR_RESET="\e[39m"
#
# The following checks are performed:
#
# - index_check: checks if the lunr.js index is built. There's two files when the
# index is built: 'lunr-index.json' and 'lunr-map.json'.
# - dev_check: when SEARCH_BACKEND is set to 'lunr' the string we're looking for
# is 'lunr.min.js'.
# This is defined in layouts/search.html.
#
if [ "$CI" = "true" ];
then
lunr_check=$(docker run --rm "$IMAGE_NAME" grep -o lunr.min.js "/usr/share/nginx/html/$GITLAB_VERSION/search/index.html")
index_check=$(docker run --rm "$IMAGE_NAME" find "/usr/share/nginx/html/$GITLAB_VERSION/assets/javascripts/lunr-index.json" | wc -l)
else
lunr_check=$(grep -o lunr.min.js public/search/index.html)
index_check=$(find public/assets/javascripts/lunr-index.json | wc -l)
fi
if [ "$index_check" != 1 ];
then
# shellcheck disable=2059
printf "${COLOR_RED}ERROR: lunr.js index is not built!\n"
printf " Did you forget to run 'make build-lunr-index'?\n"
# shellcheck disable=2059
printf " For more information, see https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/search.md#lunrjs-search${COLOR_RESET}\n"
exit 1;
else
if [ "$lunr_check" != "lunr.min.js" ];
then
# shellcheck disable=2059
printf "${COLOR_RED}ERROR: lunr.js index is found, but not enabled!\n"
printf " Did you forget to build the site with SEARCH_BACKEND='lunr'?\n"
# shellcheck disable=2059
printf " For more information, see https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/search.md#lunrjs-search${COLOR_RESET}\n"
exit 1;
else
# shellcheck disable=2059
printf "${COLOR_GREEN}INFO: lunr.js is found and enabled!${COLOR_RESET}\n"
fi
fi
|