This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
build-package.sh
executable file
·186 lines (172 loc) · 6.67 KB
/
build-package.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/sh
ATOM_CHANNEL="${ATOM_CHANNEL:=stable}"
echo "Downloading latest Atom release on the ${ATOM_CHANNEL} channel..."
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
curl -s -L "https://atom.io/download/mac?channel=${ATOM_CHANNEL}" \
-H 'Accept: application/octet-stream' \
-o "atom.zip"
mkdir atom
unzip -q atom.zip -d atom
if [ "${ATOM_CHANNEL}" = "stable" ]; then
export ATOM_APP_NAME="Atom.app"
export ATOM_SCRIPT_NAME="atom.sh"
export ATOM_SCRIPT_PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/atom.sh"
else
export ATOM_APP_NAME="Atom ${ATOM_CHANNEL}.app"
export ATOM_SCRIPT_NAME="atom-${ATOM_CHANNEL}"
export ATOM_SCRIPT_PATH="./atom-${ATOM_CHANNEL}"
ln -s "./atom/${ATOM_APP_NAME}/Contents/Resources/app/atom.sh" "${ATOM_SCRIPT_PATH}"
fi
export ATOM_PATH="./atom"
export APM_SCRIPT_PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin/apm"
export NPM_SCRIPT_PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin/npm"
export PATH="${PATH}:${TRAVIS_BUILD_DIR}/atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin"
elif [ "${TRAVIS_OS_NAME}" = "linux" ]; then
curl -s -L "https://atom.io/download/deb?channel=${ATOM_CHANNEL}" \
-H 'Accept: application/octet-stream' \
-o "atom-amd64.deb"
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
export DISPLAY=":99"
dpkg-deb -x atom-amd64.deb "${HOME}/atom"
if [ "${ATOM_CHANNEL}" = "stable" ]; then
export ATOM_SCRIPT_NAME="atom"
export APM_SCRIPT_NAME="apm"
else
export ATOM_SCRIPT_NAME="atom-${ATOM_CHANNEL}"
export APM_SCRIPT_NAME="apm-${ATOM_CHANNEL}"
fi
export ATOM_SCRIPT_PATH="${HOME}/atom/usr/bin/${ATOM_SCRIPT_NAME}"
export APM_SCRIPT_PATH="${HOME}/atom/usr/bin/${APM_SCRIPT_NAME}"
export NPM_SCRIPT_PATH="${HOME}/atom/usr/share/${ATOM_SCRIPT_NAME}/resources/app/apm/node_modules/.bin/npm"
elif [ "${CIRCLECI}" = "true" ]; then
case "${CIRCLE_BUILD_IMAGE}" in
ubuntu*)
curl -s -L "https://atom.io/download/deb?channel=${ATOM_CHANNEL}" \
-H 'Accept: application/octet-stream' \
-o "atom-amd64.deb"
sudo dpkg --install atom-amd64.deb || true
sudo apt-get update
sudo apt-get --fix-broken --assume-yes --quiet install
export ATOM_SCRIPT_PATH="atom"
export APM_SCRIPT_PATH="apm"
export NPM_SCRIPT_PATH="/usr/share/atom/resources/app/apm/node_modules/.bin/npm"
;;
osx)
curl -s -L "https://atom.io/download/mac?channel=${ATOM_CHANNEL}" \
-H 'Accept: application/octet-stream' \
-o "atom.zip"
mkdir -p /tmp/atom
unzip -q atom.zip -d /tmp/atom
if [ "${ATOM_CHANNEL}" = "stable" ]; then
export ATOM_APP_NAME="Atom.app"
export ATOM_SCRIPT_NAME="atom.sh"
export ATOM_SCRIPT_PATH="/tmp/atom/${ATOM_APP_NAME}/Contents/Resources/app/atom.sh"
else
export ATOM_APP_NAME="Atom ${ATOM_CHANNEL}.app"
export ATOM_SCRIPT_NAME="atom-${ATOM_CHANNEL}"
export ATOM_SCRIPT_PATH="/tmp/atom-${ATOM_CHANNEL}"
ln -s "/tmp/atom/${ATOM_APP_NAME}/Contents/Resources/app/atom.sh" "${ATOM_SCRIPT_PATH}"
fi
export ATOM_PATH="/tmp/atom"
export APM_SCRIPT_PATH="/tmp/atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin/apm"
export NPM_SCRIPT_PATH="/tmp/atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin/npm"
export PATH="${PATH}:${TRAVIS_BUILD_DIR}/atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin"
# Clear screen saver
osascript -e 'tell application "System Events" to keystroke "x"'
;;
*)
echo "Unsupported CircleCI OS: ${CIRCLE_BUILD_IMAGE}" >&2
exit 1
;;
esac
else
echo "Unknown CI environment, exiting!"
exit 1
fi
echo "Using Atom version:"
"${ATOM_SCRIPT_PATH}" -v
echo "Using APM version:"
"${APM_SCRIPT_PATH}" -v
echo "Downloading package dependencies..."
"${APM_SCRIPT_PATH}" clean
if [ "${ATOM_LINT_WITH_BUNDLED_NODE:=true}" = "true" ]; then
"${APM_SCRIPT_PATH}" install
# Override the PATH to put the Node bundled with APM first
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
export PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/bin:${PATH}"
elif [ "${CIRCLECI}" = "true" ] && [ "${CIRCLE_BUILD_IMAGE}" = "osx" ]; then
export PATH="/tmp/atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/bin:${PATH}"
elif [ "${CIRCLECI}" = "true" ]; then
# Since CircleCI/Linux is a fully installed environment, we use the system path to apm
export PATH="/usr/share/atom/resources/app/apm/bin:${PATH}"
else
export PATH="${HOME}/atom/usr/share/${ATOM_SCRIPT_NAME}/resources/app/apm/bin:${PATH}"
fi
else
export NPM_SCRIPT_PATH="npm"
"${APM_SCRIPT_PATH}" install --production
# Use the system NPM to install the devDependencies
echo "Using Node version:"
node --version
echo "Using NPM version:"
npm --version
echo "Installing remaining dependencies..."
npm install
fi
if [ -n "${APM_TEST_PACKAGES}" ]; then
echo "Installing atom package dependencies..."
for pack in ${APM_TEST_PACKAGES}; do
"${APM_SCRIPT_PATH}" install "${pack}"
done
fi
has_linter() {
linter_module_path="$( ${NPM_SCRIPT_PATH} ls --parseable --dev --depth=0 "$1" 2> /dev/null )"
[ -n "${linter_module_path}" ]
}
if has_linter "coffeelint"; then
if [ -d ./lib ]; then
echo "Linting package using coffeelint..."
./node_modules/.bin/coffeelint lib
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
if [ -d ./spec ]; then
echo "Linting package specs using coffeelint..."
./node_modules/.bin/coffeelint spec
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
fi
if has_linter "eslint"; then
if [ -d ./lib ]; then
echo "Linting package using eslint..."
./node_modules/.bin/eslint lib
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
if [ -d ./spec ]; then
echo "Linting package specs using eslint..."
./node_modules/.bin/eslint spec
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
fi
if has_linter "standard"; then
if [ -d ./lib ]; then
echo "Linting package using standard..."
./node_modules/.bin/standard "lib/**/*.js"
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
if [ -d ./spec ]; then
echo "Linting package specs using standard..."
./node_modules/.bin/standard "spec/**/*.js"
rc=$?; if [ $rc -ne 0 ]; then exit $rc; fi
fi
fi
if [ -d ./spec ]; then
echo "Running specs..."
"${ATOM_SCRIPT_PATH}" --test spec
elif [ -d ./test ]; then
echo "Running specs..."
"${ATOM_SCRIPT_PATH}" --test test
else
echo "Missing spec folder! Please consider adding a test suite in './spec' or in './test'"
exit 0
fi
exit