2020-04-30 13:52:54 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2020-05-08 06:34:20 +02:00
|
|
|
# This script requires vscode to be built with matching MINIFY.
|
2020-04-30 13:52:54 +02:00
|
|
|
|
2020-05-08 06:34:20 +02:00
|
|
|
# MINIFY controls whether minified vscode is bundled.
|
2020-04-30 13:52:54 +02:00
|
|
|
MINIFY="${MINIFY-true}"
|
|
|
|
|
2020-10-07 19:24:31 +02: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 13:52:54 +02:00
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
2021-09-08 21:05:49 +02:00
|
|
|
|
2020-05-16 16:55:46 +02:00
|
|
|
source ./ci/lib.sh
|
2020-05-08 05:48:49 +02:00
|
|
|
|
2022-03-15 03:37:29 +01:00
|
|
|
VSCODE_SRC_PATH="lib/vscode"
|
|
|
|
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
|
2020-04-30 13:52:54 +02:00
|
|
|
|
2022-08-22 23:07:57 +02:00
|
|
|
create_shrinkwraps
|
|
|
|
|
2020-04-30 13:52:54 +02:00
|
|
|
mkdir -p "$RELEASE_PATH"
|
|
|
|
|
|
|
|
bundle_code_server
|
|
|
|
bundle_vscode
|
|
|
|
|
2021-06-28 16:16:20 +02:00
|
|
|
rsync ./docs/README.md "$RELEASE_PATH"
|
2022-04-07 19:36:33 +02:00
|
|
|
rsync LICENSE "$RELEASE_PATH"
|
2022-03-15 03:37:29 +01:00
|
|
|
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
|
2020-04-30 13:52:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_code_server() {
|
2021-06-23 19:19:50 +02:00
|
|
|
rsync out "$RELEASE_PATH"
|
2020-04-30 13:52:54 +02: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-23 19:19:50 +02:00
|
|
|
rsync src/browser/pages/*.css "$RELEASE_PATH/src/browser/pages"
|
2020-09-15 00:34:48 +02:00
|
|
|
rsync src/browser/robots.txt "$RELEASE_PATH/src/browser"
|
2020-04-30 13:52:54 +02:00
|
|
|
|
2021-01-06 21:25:58 +01:00
|
|
|
# Add typings for plugins
|
|
|
|
mkdir -p "$RELEASE_PATH/typings"
|
2021-01-08 17:37:47 +01:00
|
|
|
rsync typings/pluginapi.d.ts "$RELEASE_PATH/typings"
|
2021-01-06 21:25:58 +01:00
|
|
|
|
2020-04-30 13:52:54 +02:00
|
|
|
# Adds the commit to package.json
|
|
|
|
jq --slurp '.[0] * .[1]' package.json <(
|
2021-06-28 18:36:55 +02:00
|
|
|
cat << EOF
|
2020-04-30 13:52:54 +02:00
|
|
|
{
|
|
|
|
"commit": "$(git rev-parse HEAD)",
|
|
|
|
"scripts": {
|
2021-09-23 20:41:51 +02:00
|
|
|
"postinstall": "sh ./postinstall.sh"
|
2020-04-30 13:52:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
2021-06-28 18:36:55 +02:00
|
|
|
) > "$RELEASE_PATH/package.json"
|
2022-03-29 19:33:56 +02:00
|
|
|
mv npm-shrinkwrap.json "$RELEASE_PATH"
|
|
|
|
|
2020-05-13 10:17:34 +02:00
|
|
|
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
|
2020-10-07 19:24:31 +02:00
|
|
|
|
|
|
|
if [ "$KEEP_MODULES" = 1 ]; then
|
|
|
|
rsync node_modules/ "$RELEASE_PATH/node_modules"
|
|
|
|
fi
|
2020-04-30 13:52:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_vscode() {
|
|
|
|
mkdir -p "$VSCODE_OUT_PATH"
|
2022-03-29 20:13:56 +02:00
|
|
|
|
2022-03-30 17:35:22 +02:00
|
|
|
local rsync_opts=()
|
|
|
|
if [[ ${DEBUG-} = 1 ]]; then
|
|
|
|
rsync_opts+=(-vh)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Some extensions have a .gitignore which excludes their built source from the
|
|
|
|
# npm package so exclude any .gitignore files.
|
|
|
|
rsync_opts+=(--exclude .gitignore)
|
|
|
|
|
|
|
|
# Exclude Node as we will add it ourselves for the standalone and will not
|
|
|
|
# need it for the npm package.
|
|
|
|
rsync_opts+=(--exclude /node)
|
|
|
|
|
|
|
|
# Exclude Node modules.
|
|
|
|
if [[ $KEEP_MODULES = 0 ]]; then
|
|
|
|
rsync_opts+=(--exclude node_modules)
|
|
|
|
fi
|
|
|
|
|
|
|
|
rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH"
|
2020-05-19 03:30:24 +02:00
|
|
|
|
2022-03-22 21:07:14 +01:00
|
|
|
# Use the package.json for the web/remote server. It does not have the right
|
2022-03-30 17:35:22 +02:00
|
|
|
# version though so pull that from the main package.json.
|
|
|
|
jq --slurp '.[0] * {version: .[1].version}' \
|
2022-03-22 21:07:14 +01:00
|
|
|
"$VSCODE_SRC_PATH/remote/package.json" \
|
|
|
|
"$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
|
|
|
|
|
2022-08-22 23:07:57 +02:00
|
|
|
mv "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
|
2022-03-22 21:07:14 +01:00
|
|
|
|
2022-03-30 17:35:22 +02:00
|
|
|
# Include global extension dependencies as well.
|
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json"
|
2022-08-22 23:07:57 +02:00
|
|
|
mv "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json"
|
2022-05-04 23:58:49 +02:00
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs"
|
2020-04-30 13:52:54 +02:00
|
|
|
}
|
|
|
|
|
2022-08-22 23:07:57 +02:00
|
|
|
create_shrinkwraps() {
|
|
|
|
# yarn.lock or package-lock.json files (used to ensure deterministic versions of dependencies) are
|
|
|
|
# not packaged when publishing to the NPM registry.
|
|
|
|
# To ensure deterministic dependency versions (even when code-server is installed with NPM), we create
|
|
|
|
# an npm-shrinkwrap.json file from the currently installed node_modules. This ensures the versions used
|
|
|
|
# from development (that the yarn.lock guarantees) are also the ones installed by end-users.
|
|
|
|
# These will include devDependencies, but those will be ignored when installing globally (for code-server), and
|
|
|
|
# because we use --omit=dev when installing vscode.
|
|
|
|
|
|
|
|
# We first generate the shrinkwrap file for code-server itself - which is the current directory
|
|
|
|
create_shrinkwrap_keeping_yarn_lock
|
|
|
|
|
|
|
|
# Then the shrinkwrap files for the bundled VSCode
|
|
|
|
pushd "$VSCODE_SRC_PATH/remote/"
|
|
|
|
create_shrinkwrap_keeping_yarn_lock
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd "$VSCODE_SRC_PATH/extensions/"
|
|
|
|
create_shrinkwrap_keeping_yarn_lock
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
create_shrinkwrap_keeping_yarn_lock() {
|
|
|
|
# HACK@edvincent: Generating a shrinkwrap alters the yarn.lock which we don't want (with NPM URLs rather than the Yarn URLs)
|
|
|
|
# But to generate a valid shrinkwrap, it has to exist... So we copy it to then restore it
|
|
|
|
cp yarn.lock yarn.lock.temp
|
|
|
|
npm shrinkwrap
|
|
|
|
cp yarn.lock.temp yarn.lock
|
|
|
|
rm yarn.lock.temp
|
|
|
|
}
|
|
|
|
|
2020-04-30 13:52:54 +02:00
|
|
|
main "$@"
|