-
Notifications
You must be signed in to change notification settings - Fork 0
/
_build-development.sh
116 lines (93 loc) · 3.7 KB
/
_build-development.sh
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
echo "$1"
# for GH Pages / GitHub Pages and Jekyll install, see:
# https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll
if command -v bundle &> /dev/null ; then
echo "Confirmed bundler is installed"
else
echo "ERROR: It appears bundler is not installed." >&2
echo "see https://jekyllrb.com/docs/installation/ubuntu/"
exit 1
fi
bundle exec jekyll --help &> /dev/null
if [ $? -eq 0 ]; then
echo "Confirmed jekyll bundle is installed"
else
bundle exec jekyll --help
echo 'Error: bundle exec jekyll is not installed or returned an error.' >&2
echo "see https://jekyllrb.com/docs/installation/ubuntu/"
exit 1
fi
if command -v sass &> /dev/null ; then
echo "Confirmed sass is installed"
else
echo ""
echo "WARNING: It appears sass is not installed. See https://sass-lang.com/install"
echo ""
fi
if command -v grunt &> /dev/null ; then
echo "Confirmed appears is installed"
else
echo ""
echo "WARNING: It appears grunt is not installed. File transformations in gruntfile.js will NOT occur."
echo ""
fi
bundle check
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Starting in $(pwd)"
# get the base url from the _config.yml file (note we want the explicit line starting with baseurl: as there are now other settings that contina the same text! )
baseurl_line=$(grep -R "^baseurl:" "_config.yml" | tail -n1)
echo "Found baseurl configuration line in _config.yml file:"
echo $baseurl_line
# get only the second parameter, not the keyword, and not any comments
baseurl=$(echo "$baseurl_line" | awk '{ print $2 }' )
# remove all slashes; we'll add our own later. note multiple subdirectory depth not supported
baseurl=$(echo "$baseurl" | tr -d / )
# remove all double quotes
baseurl=$(echo "$baseurl" | tr -d '"' )
echo "Using a value of baseurl=$baseurl"
SITE_DIR="$(pwd)/_site/"
TAG_DIR="$(pwd)/tag/"
if [ "$1" == "" ]; then
echo ""
echo "To skip prompt, add to commandline: --assume-yes"
echo ""
fi
# Optional prompt to delete files in _site directory (yes, I've seen cached files get seemingly stuck there!')
if [ "$1" == "--assume-yes" ]; then
# we have a chicken-and-egg problem with the tag directory: it needs to get copied FROM the _site directory, AFTER generation, but it gets copied before - so we need to wipe it out
echo "Removing files in $TAG_DIR ..."
rm -Rf $TAG_DIR
echo "Removing files in $SITE_DIR ..."
rm -Rf $SITE_DIR
else
read -p "Delete files in $SITE_DIR? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] && if [ -d "$SITE_DIR" ]; then rm -Rf $SITE_DIR; rm -Rf $TAG_DIR; fi
fi
echo ""
mkdir -p $TAG_DIR
echo "WARNING: this is an auto-generated directory to fix missing tag files. See _build-development.sh\n" > $TAG_DIR/README.md
if [ "$1" == "--assume-yes" ]; then
echo "Skipping browser launch for $1"
echo ""
echo "View web page at: http://127.0.0.1:4000/$baseurl/"
echo ""
else
echo "launching browser for baseurl=$baseurl found in_config.yml"
if [ "$baseurl" == "" ]; then
python3 -mwebbrowser http://127.0.0.1:4000/
else
python3 -mwebbrowser http://127.0.0.1:4000/$baseurl/
fi
fi
# we'll gnerate a full website without serving it up to allow for a manual copy of site tag files
echo "[optional] bundle exec jekyll build --trace"
bundle exec jekyll build --trace
echo ""
echo "Fix for tag pages: manually copy from _site/tag/* to ./tag/ (using previously generated files!)"
echo "Copy in $(pwd) using command: cp --recursive ./_site/tag/* ./tag"
mkdir -p ./tag
cp --recursive ./_site/tag/* ./tag
echo "Copy complete."
echo ""
echo "running: bundle exec jekyll serve --profile --incremental --drafts"
bundle exec jekyll serve --profile --incremental --drafts