2020-04-30 13:52:54 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Builds code-server into out and the frontend into dist.
|
|
|
|
|
|
|
|
# MINIFY controls whether parcel minifies dist.
|
|
|
|
MINIFY=${MINIFY-true}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
|
|
|
|
2020-08-04 22:05:13 +02:00
|
|
|
tsc
|
|
|
|
|
2020-04-30 13:52:54 +02:00
|
|
|
# If out/node/entry.js does not already have the shebang,
|
|
|
|
# we make sure to add it and make it executable.
|
|
|
|
if ! grep -q -m1 "^#!/usr/bin/env node" out/node/entry.js; then
|
|
|
|
sed -i.bak "1s;^;#!/usr/bin/env node\n;" out/node/entry.js && rm out/node/entry.js.bak
|
|
|
|
chmod +x out/node/entry.js
|
|
|
|
fi
|
|
|
|
|
2020-10-06 20:19:04 +02:00
|
|
|
if ! [ -f ./lib/coder-cloud-agent ]; then
|
2021-05-05 18:23:30 +02:00
|
|
|
echo "Downloading the cloud agent..."
|
|
|
|
|
|
|
|
# for arch; we do not use OS from lib.sh and get our own.
|
|
|
|
# lib.sh normalizes macos to darwin - but cloud-agent's binaries do not
|
|
|
|
source ./ci/lib.sh
|
2020-10-06 20:19:04 +02:00
|
|
|
OS="$(uname | tr '[:upper:]' '[:lower:]')"
|
2021-05-05 18:23:30 +02:00
|
|
|
|
2020-12-14 21:18:10 +01:00
|
|
|
set +e
|
2021-05-05 18:23:30 +02:00
|
|
|
curl -fsSL "https://github.com/cdr/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent
|
2020-10-06 20:19:04 +02:00
|
|
|
chmod +x ./lib/coder-cloud-agent
|
2020-12-14 21:18:10 +01:00
|
|
|
set -e
|
2020-10-06 20:19:04 +02:00
|
|
|
fi
|
|
|
|
|
2020-05-22 21:38:03 +02:00
|
|
|
parcel build \
|
2020-07-29 22:02:14 +02:00
|
|
|
--public-url "." \
|
2020-04-30 13:52:54 +02:00
|
|
|
--out-dir dist \
|
|
|
|
$([[ $MINIFY ]] || echo --no-minify) \
|
|
|
|
src/browser/register.ts \
|
2020-08-04 22:03:22 +02:00
|
|
|
src/browser/serviceWorker.ts \
|
|
|
|
src/browser/pages/login.ts \
|
|
|
|
src/browser/pages/vscode.ts
|
2020-04-30 13:52:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|