2020-04-30 18:52:54 +07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2020-05-08 11:34:20 +07:00
|
|
|
# This script requires vscode to be built with matching MINIFY.
|
2020-04-30 18:52:54 +07:00
|
|
|
|
2020-05-08 11:34:20 +07:00
|
|
|
# MINIFY controls whether minified vscode is bundled.
|
2020-04-30 18:52:54 +07:00
|
|
|
MINIFY="${MINIFY-true}"
|
|
|
|
|
2020-10-08 00:24:31 +07: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 18:52:54 +07:00
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
2020-05-16 21:55:46 +07:00
|
|
|
source ./ci/lib.sh
|
2020-05-08 10:48:49 +07:00
|
|
|
|
|
|
|
VSCODE_SRC_PATH="lib/vscode"
|
|
|
|
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
|
2020-04-30 18:52:54 +07:00
|
|
|
|
|
|
|
mkdir -p "$RELEASE_PATH"
|
|
|
|
|
|
|
|
bundle_code_server
|
|
|
|
bundle_vscode
|
|
|
|
|
2021-06-28 21:16:20 +07:00
|
|
|
rsync ./docs/README.md "$RELEASE_PATH"
|
2020-04-30 18:52:54 +07:00
|
|
|
rsync LICENSE.txt "$RELEASE_PATH"
|
|
|
|
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
|
|
|
|
}
|
|
|
|
|
|
|
|
bundle_code_server() {
|
2021-06-24 00:19:50 +07:00
|
|
|
rsync out "$RELEASE_PATH"
|
2020-04-30 18:52:54 +07:00
|
|
|
|
|
|
|
# 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"
|
2021-06-24 00:19:50 +07:00
|
|
|
rsync src/browser/pages/*.css "$RELEASE_PATH/src/browser/pages"
|
2020-09-15 05:34:48 +07:00
|
|
|
rsync src/browser/robots.txt "$RELEASE_PATH/src/browser"
|
2020-04-30 18:52:54 +07:00
|
|
|
|
2021-01-07 03:25:58 +07:00
|
|
|
# Add typings for plugins
|
|
|
|
mkdir -p "$RELEASE_PATH/typings"
|
2021-01-08 23:37:47 +07:00
|
|
|
rsync typings/pluginapi.d.ts "$RELEASE_PATH/typings"
|
2021-01-07 03:25:58 +07:00
|
|
|
|
2020-04-30 18:52:54 +07:00
|
|
|
# Adds the commit to package.json
|
|
|
|
jq --slurp '.[0] * .[1]' package.json <(
|
2021-06-28 23:36:55 +07:00
|
|
|
cat << EOF
|
2020-04-30 18:52:54 +07:00
|
|
|
{
|
|
|
|
"commit": "$(git rev-parse HEAD)",
|
|
|
|
"scripts": {
|
2020-05-13 15:17:34 +07:00
|
|
|
"postinstall": "./postinstall.sh"
|
2020-04-30 18:52:54 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
2021-06-28 23:36:55 +07:00
|
|
|
) > "$RELEASE_PATH/package.json"
|
2020-05-13 15:17:34 +07:00
|
|
|
rsync yarn.lock "$RELEASE_PATH"
|
|
|
|
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
|
2020-10-08 00:24:31 +07:00
|
|
|
|
|
|
|
if [ "$KEEP_MODULES" = 1 ]; then
|
|
|
|
rsync node_modules/ "$RELEASE_PATH/node_modules"
|
2020-10-13 05:26:50 +07:00
|
|
|
mkdir -p "$RELEASE_PATH/lib"
|
2020-10-12 13:09:48 +07:00
|
|
|
rsync ./lib/coder-cloud-agent "$RELEASE_PATH/lib"
|
2020-10-08 00:24:31 +07:00
|
|
|
fi
|
2020-04-30 18:52:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_vscode() {
|
|
|
|
mkdir -p "$VSCODE_OUT_PATH"
|
2020-05-13 13:35:11 +07:00
|
|
|
rsync "$VSCODE_SRC_PATH/yarn.lock" "$VSCODE_OUT_PATH"
|
2020-10-30 02:48:01 +07:00
|
|
|
rsync "$VSCODE_SRC_PATH/out-vscode${MINIFY:+-min}/" "$VSCODE_OUT_PATH/out"
|
2020-05-19 08:30:24 +07:00
|
|
|
|
2020-04-30 18:52:54 +07:00
|
|
|
rsync "$VSCODE_SRC_PATH/.build/extensions/" "$VSCODE_OUT_PATH/extensions"
|
2020-10-08 00:24:31 +07: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 08:30:24 +07: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 18:52:54 +07:00
|
|
|
|
2021-01-06 04:26:11 +07:00
|
|
|
mkdir -p "$VSCODE_OUT_PATH/resources/"{linux,web}
|
2020-04-30 18:52:54 +07:00
|
|
|
rsync "$VSCODE_SRC_PATH/resources/linux/code.png" "$VSCODE_OUT_PATH/resources/linux/code.png"
|
2021-01-06 04:26:11 +07:00
|
|
|
rsync "$VSCODE_SRC_PATH/resources/web/callback.html" "$VSCODE_OUT_PATH/resources/web/callback.html"
|
2020-04-30 18:52:54 +07:00
|
|
|
|
|
|
|
# Adds the commit and date to product.json
|
|
|
|
jq --slurp '.[0] * .[1]' "$VSCODE_SRC_PATH/product.json" <(
|
2021-06-28 23:36:55 +07:00
|
|
|
cat << EOF
|
2020-04-30 18:52:54 +07:00
|
|
|
{
|
|
|
|
"commit": "$(git rev-parse HEAD)",
|
|
|
|
"date": $(jq -n 'now | todate')
|
|
|
|
}
|
|
|
|
EOF
|
2021-06-28 23:36:55 +07:00
|
|
|
) > "$VSCODE_OUT_PATH/product.json"
|
2020-04-30 18:52:54 +07:00
|
|
|
|
2020-05-19 08:30:24 +07: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 17:19:09 +07:00
|
|
|
# We cannot use --no-scripts because we still want dependent package scripts to run.
|
2021-06-28 23:36:55 +07:00
|
|
|
jq 'del(.scripts)' < "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
|
2020-12-18 04:16:04 +07:00
|
|
|
|
|
|
|
pushd "$VSCODE_OUT_PATH"
|
|
|
|
symlink_asar
|
|
|
|
popd
|
2020-04-30 18:52:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|