2020-04-30 19:52:54 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2022-03-15 10:37:29 +08:00
|
|
|
# Builds vscode into lib/vscode/out-vscode.
|
2020-04-30 19:52:54 +08:00
|
|
|
|
|
|
|
# MINIFY controls whether a minified version of vscode is built.
|
|
|
|
MINIFY=${MINIFY-true}
|
|
|
|
|
2022-08-05 00:03:28 +08:00
|
|
|
delete-bin-script() {
|
|
|
|
rm -f "lib/vscode-reh-web-linux-x64/bin/$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
copy-bin-script() {
|
|
|
|
local script="$1"
|
|
|
|
local dest="lib/vscode-reh-web-linux-x64/bin/$script"
|
|
|
|
cp "lib/vscode/resources/server/bin/$script" "$dest"
|
|
|
|
sed -i.bak "s/@@VERSION@@/$(vscode_version)/g" "$dest"
|
2023-05-16 07:44:03 +08:00
|
|
|
sed -i.bak "s/@@COMMIT@@/$BUILD_SOURCEVERSION/g" "$dest"
|
2022-08-05 00:03:28 +08:00
|
|
|
sed -i.bak "s/@@APPNAME@@/code-server/g" "$dest"
|
|
|
|
|
|
|
|
# Fix Node path on Darwin and Linux.
|
|
|
|
# We do not want expansion here; this text should make it to the file as-is.
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
sed -i.bak 's/^ROOT=\(.*\)$/VSROOT=\1\nROOT="$(dirname "$(dirname "$VSROOT")")"/g' "$dest"
|
|
|
|
sed -i.bak 's/ROOT\/out/VSROOT\/out/g' "$dest"
|
2022-09-30 07:02:53 +08:00
|
|
|
# We do not want expansion here; this text should make it to the file as-is.
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
sed -i.bak 's/$ROOT\/node/${NODE_EXEC_PATH:-$ROOT\/lib\/node}/g' "$dest"
|
2022-08-05 00:03:28 +08:00
|
|
|
|
|
|
|
# Fix Node path on Windows.
|
|
|
|
sed -i.bak 's/^set ROOT_DIR=\(.*\)$/set ROOT_DIR=%~dp0..\\..\\..\\..\r\nset VSROOT_DIR=\1/g' "$dest"
|
|
|
|
sed -i.bak 's/%ROOT_DIR%\\out/%VSROOT_DIR%\\out/g' "$dest"
|
|
|
|
|
|
|
|
chmod +x "$dest"
|
|
|
|
rm "$dest.bak"
|
|
|
|
}
|
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
2021-09-09 03:05:49 +08:00
|
|
|
|
2022-06-22 05:51:46 +08:00
|
|
|
source ./ci/lib.sh
|
|
|
|
|
2023-09-30 05:56:21 +08:00
|
|
|
# Set the commit Code will embed into the product.json. We need to do this
|
|
|
|
# since Code tries to get the commit from the `.git` directory which will fail
|
|
|
|
# as it is a submodule.
|
|
|
|
#
|
|
|
|
# Also, we use code-server's commit rather than VS Code's otherwise it would
|
|
|
|
# not update when only our patch files change, and that will cause caching
|
|
|
|
# issues where the browser keeps using outdated code.
|
|
|
|
export BUILD_SOURCEVERSION
|
|
|
|
BUILD_SOURCEVERSION=$(git rev-parse HEAD)
|
|
|
|
|
2022-08-05 00:03:28 +08:00
|
|
|
pushd lib/vscode
|
2020-04-30 19:52:54 +08:00
|
|
|
|
2022-12-02 00:51:07 +08:00
|
|
|
if [[ ! ${VERSION-} ]]; then
|
|
|
|
echo "VERSION not set. Please set before running this script:"
|
2024-10-18 12:31:28 +08:00
|
|
|
echo "VERSION='0.0.0' npm run build:vscode"
|
2022-12-02 00:51:07 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-09-30 02:37:20 +08:00
|
|
|
# Add the date, our name, links, enable telemetry (this just makes telemetry
|
|
|
|
# available; telemetry can still be disabled by flag or setting), and
|
|
|
|
# configure trusted extensions (since some, like github.copilot-chat, never
|
|
|
|
# ask to be trusted and this is the only way to get auth working).
|
|
|
|
#
|
2022-06-22 05:51:46 +08:00
|
|
|
# This needs to be done before building as Code will read this file and embed
|
|
|
|
# it into the client-side code.
|
|
|
|
git checkout product.json # Reset in case the script exited early.
|
|
|
|
cp product.json product.original.json # Since jq has no inline edit.
|
|
|
|
jq --slurp '.[0] * .[1]' product.original.json <(
|
|
|
|
cat << EOF
|
|
|
|
{
|
|
|
|
"enableTelemetry": true,
|
|
|
|
"quality": "stable",
|
|
|
|
"codeServerVersion": "$VERSION",
|
|
|
|
"nameShort": "code-server",
|
|
|
|
"nameLong": "code-server",
|
|
|
|
"applicationName": "code-server",
|
|
|
|
"dataFolderName": ".code-server",
|
|
|
|
"win32MutexName": "codeserver",
|
|
|
|
"licenseUrl": "https://github.com/coder/code-server/blob/main/LICENSE",
|
|
|
|
"win32DirName": "code-server",
|
|
|
|
"win32NameVersion": "code-server",
|
|
|
|
"win32AppUserModelId": "coder.code-server",
|
|
|
|
"win32ShellNameShort": "c&ode-server",
|
|
|
|
"darwinBundleIdentifier": "com.coder.code.server",
|
|
|
|
"linuxIconName": "com.coder.code.server",
|
|
|
|
"reportIssueUrl": "https://github.com/coder/code-server/issues/new",
|
|
|
|
"documentationUrl": "https://go.microsoft.com/fwlink/?LinkID=533484#vscode",
|
|
|
|
"keyboardShortcutsUrlMac": "https://go.microsoft.com/fwlink/?linkid=832143",
|
|
|
|
"keyboardShortcutsUrlLinux": "https://go.microsoft.com/fwlink/?linkid=832144",
|
|
|
|
"keyboardShortcutsUrlWin": "https://go.microsoft.com/fwlink/?linkid=832145",
|
|
|
|
"introductoryVideosUrl": "https://go.microsoft.com/fwlink/?linkid=832146",
|
|
|
|
"tipsAndTricksUrl": "https://go.microsoft.com/fwlink/?linkid=852118",
|
|
|
|
"newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter",
|
|
|
|
"linkProtectionTrustedDomains": [
|
2023-09-30 05:56:21 +08:00
|
|
|
"https://open-vsx.org"
|
2023-09-30 02:37:20 +08:00
|
|
|
],
|
|
|
|
"trustedExtensionAuthAccess": [
|
|
|
|
"vscode.git", "vscode.github",
|
|
|
|
"github.vscode-pull-request-github",
|
|
|
|
"github.copilot", "github.copilot-chat"
|
2022-09-24 06:51:41 +08:00
|
|
|
],
|
|
|
|
"aiConfig": {
|
|
|
|
"ariaKey": "code-server"
|
|
|
|
}
|
2022-06-22 05:51:46 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
) > product.json
|
|
|
|
|
2022-08-05 00:03:28 +08:00
|
|
|
# Any platform here works since we will do our own packaging. We have to do
|
|
|
|
# this because we have an NPM package that could be installed on any platform.
|
|
|
|
# The correct platform dependencies and scripts will be installed as part of
|
|
|
|
# the post-install during `npm install` or when building a standalone release.
|
2024-10-18 12:31:28 +08:00
|
|
|
npm run gulp "vscode-reh-web-linux-x64${MINIFY:+-min}"
|
2022-06-22 05:51:46 +08:00
|
|
|
|
|
|
|
# Reset so if you develop after building you will not be stuck with the wrong
|
|
|
|
# commit (the dev client will use `oss-dev` but the dev server will still use
|
|
|
|
# product.json which will have `stable-$commit`).
|
|
|
|
git checkout product.json
|
2022-08-05 00:03:28 +08:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
2023-05-16 07:44:03 +08:00
|
|
|
pushd lib/vscode-reh-web-linux-x64
|
|
|
|
# Make sure Code took the version we set in the environment variable. Not
|
|
|
|
# having a version will break display languages.
|
2023-06-01 07:00:58 +08:00
|
|
|
if ! jq -e .commit product.json; then
|
2023-05-16 07:44:03 +08:00
|
|
|
echo "'commit' is missing from product.json"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
2022-08-05 00:03:28 +08:00
|
|
|
# These provide a `code-server` command in the integrated terminal to open
|
|
|
|
# files in the current instance.
|
|
|
|
delete-bin-script remote-cli/code-server
|
|
|
|
copy-bin-script remote-cli/code-darwin.sh
|
|
|
|
copy-bin-script remote-cli/code-linux.sh
|
|
|
|
copy-bin-script remote-cli/code.cmd
|
|
|
|
|
|
|
|
# These provide a way for terminal applications to open browser windows.
|
|
|
|
delete-bin-script helpers/browser.sh
|
|
|
|
copy-bin-script helpers/browser-darwin.sh
|
|
|
|
copy-bin-script helpers/browser-linux.sh
|
|
|
|
copy-bin-script helpers/browser.cmd
|
2020-04-30 19:52:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|