2020-04-30 14:52:54 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2020-05-08 07:34:20 +03:00
|
|
|
# This script requires vscode to be built with matching MINIFY.
|
2020-04-30 14:52:54 +03:00
|
|
|
|
2020-05-08 07:34:20 +03:00
|
|
|
# MINIFY controls whether minified vscode is bundled.
|
2020-04-30 14:52:54 +03:00
|
|
|
MINIFY="${MINIFY-true}"
|
|
|
|
|
2020-10-07 20:24:31 +03:00
|
|
|
# KEEP_MODULES controls whether the script cleans all node_modules requiring a yarn install
|
|
|
|
# to run first.
|
|
|
|
KEEP_MODULES="${KEEP_MODULES-0}"
|
|
|
|
|
2020-04-30 14:52:54 +03:00
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
2020-05-16 17:55:46 +03:00
|
|
|
source ./ci/lib.sh
|
2020-05-08 06:48:49 +03:00
|
|
|
|
|
|
|
VSCODE_SRC_PATH="lib/vscode"
|
|
|
|
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
|
2020-04-30 14:52:54 +03:00
|
|
|
|
|
|
|
mkdir -p "$RELEASE_PATH"
|
|
|
|
|
|
|
|
bundle_code_server
|
|
|
|
bundle_vscode
|
|
|
|
|
|
|
|
rsync README.md "$RELEASE_PATH"
|
|
|
|
rsync LICENSE.txt "$RELEASE_PATH"
|
|
|
|
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
|
2020-10-06 21:19:04 +03:00
|
|
|
rsync ./lib/coder-cloud-agent "$RELEASE_PATH/lib"
|
2020-07-28 23:06:10 +03:00
|
|
|
|
2020-08-05 20:58:48 +03:00
|
|
|
# code-server exports types which can be imported and used by plugins. Those
|
|
|
|
# types import ipc.d.ts but it isn't included in the final vscode build so
|
|
|
|
# we'll copy it ourselves here.
|
2020-07-28 23:06:10 +03:00
|
|
|
mkdir -p "$RELEASE_PATH/lib/vscode/src/vs/server"
|
|
|
|
rsync ./lib/vscode/src/vs/server/ipc.d.ts "$RELEASE_PATH/lib/vscode/src/vs/server"
|
2020-04-30 14:52:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_code_server() {
|
|
|
|
rsync out dist "$RELEASE_PATH"
|
|
|
|
|
|
|
|
# For source maps and images.
|
|
|
|
mkdir -p "$RELEASE_PATH/src/browser"
|
|
|
|
rsync src/browser/media/ "$RELEASE_PATH/src/browser/media"
|
|
|
|
mkdir -p "$RELEASE_PATH/src/browser/pages"
|
|
|
|
rsync src/browser/pages/*.html "$RELEASE_PATH/src/browser/pages"
|
2020-09-15 01:34:48 +03:00
|
|
|
rsync src/browser/robots.txt "$RELEASE_PATH/src/browser"
|
2020-04-30 14:52:54 +03:00
|
|
|
|
|
|
|
# Adds the commit to package.json
|
|
|
|
jq --slurp '.[0] * .[1]' package.json <(
|
|
|
|
cat << EOF
|
|
|
|
{
|
|
|
|
"commit": "$(git rev-parse HEAD)",
|
|
|
|
"scripts": {
|
2020-05-13 11:17:34 +03:00
|
|
|
"postinstall": "./postinstall.sh"
|
2020-04-30 14:52:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
) > "$RELEASE_PATH/package.json"
|
2020-05-13 11:17:34 +03:00
|
|
|
rsync yarn.lock "$RELEASE_PATH"
|
|
|
|
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
|
2020-10-07 20:24:31 +03:00
|
|
|
|
|
|
|
if [ "$KEEP_MODULES" = 1 ]; then
|
|
|
|
rsync node_modules/ "$RELEASE_PATH/node_modules"
|
|
|
|
fi
|
2020-04-30 14:52:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_vscode() {
|
|
|
|
mkdir -p "$VSCODE_OUT_PATH"
|
2020-05-13 09:35:11 +03:00
|
|
|
rsync "$VSCODE_SRC_PATH/yarn.lock" "$VSCODE_OUT_PATH"
|
2020-04-30 14:52:54 +03:00
|
|
|
rsync "$VSCODE_SRC_PATH/out-vscode${MINIFY+-min}/" "$VSCODE_OUT_PATH/out"
|
2020-05-19 04:30:24 +03:00
|
|
|
|
2020-04-30 14:52:54 +03:00
|
|
|
rsync "$VSCODE_SRC_PATH/.build/extensions/" "$VSCODE_OUT_PATH/extensions"
|
2020-10-07 20:24:31 +03:00
|
|
|
if [ "$KEEP_MODULES" = 0 ]; then
|
|
|
|
rm -Rf "$VSCODE_OUT_PATH/extensions/node_modules"
|
|
|
|
else
|
|
|
|
rsync "$VSCODE_SRC_PATH/node_modules/" "$VSCODE_OUT_PATH/node_modules"
|
|
|
|
fi
|
2020-05-19 04:30:24 +03:00
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions"
|
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions"
|
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions"
|
2020-04-30 14:52:54 +03:00
|
|
|
|
|
|
|
mkdir -p "$VSCODE_OUT_PATH/resources/linux"
|
|
|
|
rsync "$VSCODE_SRC_PATH/resources/linux/code.png" "$VSCODE_OUT_PATH/resources/linux/code.png"
|
|
|
|
|
|
|
|
# Adds the commit and date to product.json
|
|
|
|
jq --slurp '.[0] * .[1]' "$VSCODE_SRC_PATH/product.json" <(
|
|
|
|
cat << EOF
|
|
|
|
{
|
|
|
|
"commit": "$(git rev-parse HEAD)",
|
|
|
|
"date": $(jq -n 'now | todate')
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
) > "$VSCODE_OUT_PATH/product.json"
|
|
|
|
|
2020-05-19 04:30:24 +03:00
|
|
|
# We remove the scripts field so that later on we can run
|
|
|
|
# yarn to fetch node_modules if necessary without build scripts running.
|
2020-05-19 13:19:09 +03:00
|
|
|
# We cannot use --no-scripts because we still want dependent package scripts to run.
|
2020-05-19 04:30:24 +03:00
|
|
|
jq 'del(.scripts)' < "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
|
2020-04-30 14:52:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|