mirror of
https://github.com/danog/code-server.git
synced 2024-12-02 17:56:04 +01:00
1739b21600
Many random bizarre issues otherwise. Also includes misc improvements to docs and scripts.
85 lines
2.2 KiB
Bash
Executable File
85 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# This script requires vscode to be built with matching MINIFY.
|
|
|
|
# MINIFY controls whether minified vscode is bundled.
|
|
MINIFY="${MINIFY-true}"
|
|
|
|
main() {
|
|
cd "$(dirname "${0}")/../.."
|
|
source ./ci/build/lib.sh
|
|
|
|
VSCODE_SRC_PATH="lib/vscode"
|
|
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
|
|
|
|
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"
|
|
}
|
|
|
|
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"
|
|
|
|
rsync yarn.lock "$RELEASE_PATH"
|
|
|
|
# Adds the commit to package.json
|
|
jq --slurp '.[0] * .[1]' package.json <(
|
|
cat << EOF
|
|
{
|
|
"commit": "$(git rev-parse HEAD)",
|
|
"scripts": {
|
|
"postinstall": "cd lib/vscode && npm rebuild # Builds native modules"
|
|
}
|
|
}
|
|
EOF
|
|
) > "$RELEASE_PATH/package.json"
|
|
}
|
|
|
|
bundle_vscode() {
|
|
mkdir -p "$VSCODE_OUT_PATH"
|
|
rsync "$VSCODE_SRC_PATH/package.json" "$VSCODE_OUT_PATH"
|
|
rsync "$VSCODE_SRC_PATH/yarn.lock" "$VSCODE_OUT_PATH"
|
|
rsync "$VSCODE_SRC_PATH/node_modules" "$VSCODE_OUT_PATH"
|
|
rsync "$VSCODE_SRC_PATH/out-vscode${MINIFY+-min}/" "$VSCODE_OUT_PATH/out"
|
|
rsync "$VSCODE_SRC_PATH/.build/extensions/" "$VSCODE_OUT_PATH/extensions"
|
|
|
|
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"
|
|
|
|
pushd "$VSCODE_OUT_PATH"
|
|
yarn --production --ignore-scripts
|
|
popd
|
|
|
|
# Now we clear any native module builds.
|
|
local nativeModules
|
|
mapfile -t nativeModules < <(find "$VSCODE_OUT_PATH/node_modules" -name "binding.gyp" -exec dirname {} \;)
|
|
local nm
|
|
for nm in "${nativeModules[@]}"; do
|
|
rm -R "$nm/build"
|
|
done
|
|
}
|
|
|
|
main "$@"
|