This repository was archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathgenerate-docs.sh
More file actions
executable file
·116 lines (104 loc) · 2.95 KB
/
generate-docs.sh
File metadata and controls
executable file
·116 lines (104 loc) · 2.95 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
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
#!/bin/sh
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
# Check number of parameters
if [ "$#" -gt 1 ]; then
echo "Usage: ./scripts/generate-docs.sh [commit_ref]"
exit 1
fi
# Check that directory is clean
if [ $(git status --porcelain | wc -l) != "0" ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "We cannot push the generated docs unless the working directory is" 1>&2
echo "clean. Either commit your changes, stash them, or generate the" 1>&2
echo "docs manually by running gulp in /website/ and push them to" 1>&2
echo "gh-pages at a later date." 1>&2
echo -e "\033[0m" 1>&2 # Normal color
exit 1
fi
# If a commit ref is passed as a command line option, use that.
# Otherwise, default to the tag corresponding to the version in package.json.
if [ "$#" -eq 0 ]; then
VERSION=$(node scripts/get-version.js)
else
VERSION=$1
fi
EXEC_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Switching to ${VERSION}..."
git checkout "${VERSION}"
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
if [ "$#" -eq 0 ]; then
echo "The package.json file indicates that the current version is" 1>&2
echo "\"${VERSION}\", but there is no corresponding git tag." 1>&2
else
echo "Cannot checkout \"${VERSION}\"." 1>&2
fi
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi
echo "Removing temp files..."
git clean -fxd
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Could not remove untracked/ignored files."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi
echo "Main \`npm install\`..."
npm install
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "\`npm install\` failed."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi
# Compile to es5
./scripts/compile_to_es5.sh
if [ $? -ne 0 ]; then
git checkout "${EXEC_BRANCH}"
exit 1
fi
echo "Installing the testapp..."
npm run install_testapp
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Couldn't install testapp."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi
echo "Installing the website..."
cd website
npm install
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Failed to install website dependencies."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi
echo "Building the website..."
npm run build
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Website build failed."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi
echo "Transfering files to gh-pages..."
cd ".."
git branch -D gh-pages
git pull -f https://github.com/angular/protractor.git gh-pages:gh-pages
git reset --hard
git checkout gh-pages
cp -r website/build/* .
git add -A
git commit -m "chore(website): automatic docs update for ${VERSION}"
echo -e "\033[0;32m" # Green
echo "Created update commit in gh-pages branch."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"