2020-04-30 19:52:54 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2024-10-18 12:31:28 +08:00
|
|
|
# Once both code-server and VS Code have been built, use this script to copy
|
|
|
|
# them into a single directory (./release), prepare the package.json and
|
|
|
|
# product.json, and add shrinkwraps. This results in a generic NPM package that
|
|
|
|
# we published to NPM and also use to compile platform-specific packages.
|
2020-04-30 19:52:54 +08:00
|
|
|
|
2024-10-18 12:31:28 +08:00
|
|
|
# MINIFY controls whether minified VS Code is bundled. It must match the value
|
|
|
|
# used when VS Code was built.
|
2020-04-30 19:52:54 +08:00
|
|
|
MINIFY="${MINIFY-true}"
|
|
|
|
|
2024-10-18 12:31:28 +08:00
|
|
|
# node_modules are not copied by default. Set KEEP_MODULES=1 to copy them.
|
2020-10-08 01:24:31 +08:00
|
|
|
KEEP_MODULES="${KEEP_MODULES-0}"
|
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
main() {
|
|
|
|
cd "$(dirname "${0}")/../.."
|
2021-09-09 03:05:49 +08:00
|
|
|
|
2020-05-16 22:55:46 +08:00
|
|
|
source ./ci/lib.sh
|
2020-05-08 11:48:49 +08:00
|
|
|
|
2022-03-15 10:37:29 +08:00
|
|
|
VSCODE_SRC_PATH="lib/vscode"
|
|
|
|
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
|
2020-04-30 19:52:54 +08:00
|
|
|
|
2022-08-23 05:07:57 +08:00
|
|
|
create_shrinkwraps
|
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
mkdir -p "$RELEASE_PATH"
|
|
|
|
|
|
|
|
bundle_code_server
|
|
|
|
bundle_vscode
|
|
|
|
|
2021-06-28 22:16:20 +08:00
|
|
|
rsync ./docs/README.md "$RELEASE_PATH"
|
2022-04-08 01:36:33 +08:00
|
|
|
rsync LICENSE "$RELEASE_PATH"
|
2022-03-15 10:37:29 +08:00
|
|
|
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
|
2020-04-30 19:52:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_code_server() {
|
2021-06-24 01:19:50 +08:00
|
|
|
rsync out "$RELEASE_PATH"
|
2020-04-30 19:52:54 +08: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 01:19:50 +08:00
|
|
|
rsync src/browser/pages/*.css "$RELEASE_PATH/src/browser/pages"
|
2020-09-15 06:34:48 +08:00
|
|
|
rsync src/browser/robots.txt "$RELEASE_PATH/src/browser"
|
2020-04-30 19:52:54 +08:00
|
|
|
|
2021-01-07 04:25:58 +08:00
|
|
|
# Add typings for plugins
|
|
|
|
mkdir -p "$RELEASE_PATH/typings"
|
2021-01-09 00:37:47 +08:00
|
|
|
rsync typings/pluginapi.d.ts "$RELEASE_PATH/typings"
|
2021-01-07 04:25:58 +08:00
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
# Adds the commit to package.json
|
2024-10-18 12:31:28 +08:00
|
|
|
jq --slurp '(.[0] | del(.scripts,.jest,.devDependencies)) * .[1]' package.json <(
|
2021-06-29 00:36:55 +08:00
|
|
|
cat << EOF
|
2020-04-30 19:52:54 +08:00
|
|
|
{
|
|
|
|
"commit": "$(git rev-parse HEAD)",
|
|
|
|
"scripts": {
|
2021-09-24 02:41:51 +08:00
|
|
|
"postinstall": "sh ./postinstall.sh"
|
2020-04-30 19:52:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
2021-06-29 00:36:55 +08:00
|
|
|
) > "$RELEASE_PATH/package.json"
|
2022-03-30 01:33:56 +08:00
|
|
|
mv npm-shrinkwrap.json "$RELEASE_PATH"
|
|
|
|
|
2020-05-13 16:17:34 +08:00
|
|
|
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
|
2020-10-08 01:24:31 +08:00
|
|
|
|
|
|
|
if [ "$KEEP_MODULES" = 1 ]; then
|
|
|
|
rsync node_modules/ "$RELEASE_PATH/node_modules"
|
|
|
|
fi
|
2020-04-30 19:52:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bundle_vscode() {
|
|
|
|
mkdir -p "$VSCODE_OUT_PATH"
|
2022-03-30 02:13:56 +08:00
|
|
|
|
2022-03-30 23:35:22 +08: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 09:30:24 +08:00
|
|
|
|
2024-10-18 12:31:28 +08:00
|
|
|
# Merge the package.json for the web/remote server so we can include
|
|
|
|
# dependencies, since we want to ship this via NPM.
|
|
|
|
jq --slurp '.[0] * .[1]' \
|
2022-03-23 04:07:14 +08:00
|
|
|
"$VSCODE_SRC_PATH/remote/package.json" \
|
2024-10-18 12:31:28 +08:00
|
|
|
"$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged"
|
|
|
|
mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json"
|
|
|
|
cp "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
|
2022-03-23 04:07:14 +08:00
|
|
|
|
2022-03-30 23:35:22 +08:00
|
|
|
# Include global extension dependencies as well.
|
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json"
|
2024-10-18 12:31:28 +08:00
|
|
|
cp "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json"
|
2022-05-05 05:58:49 +08:00
|
|
|
rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs"
|
2020-04-30 19:52:54 +08:00
|
|
|
}
|
|
|
|
|
2022-08-23 05:07:57 +08:00
|
|
|
create_shrinkwraps() {
|
2024-10-18 12:31:28 +08:00
|
|
|
# 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 package-lock.json 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 (for VS Code).
|
|
|
|
|
|
|
|
# We first generate the shrinkwrap file for code-server itself - which is the
|
|
|
|
# current directory.
|
|
|
|
cp package-lock.json package-lock.json.temp
|
|
|
|
npm shrinkwrap
|
|
|
|
mv package-lock.json.temp package-lock.json
|
|
|
|
|
|
|
|
# Then the shrinkwrap files for the bundled VS Code.
|
2022-08-23 05:07:57 +08:00
|
|
|
pushd "$VSCODE_SRC_PATH/remote/"
|
2024-10-18 12:31:28 +08:00
|
|
|
cp package-lock.json package-lock.json.temp
|
|
|
|
npm shrinkwrap
|
|
|
|
mv package-lock.json.temp package-lock.json
|
2022-08-23 05:07:57 +08:00
|
|
|
popd
|
|
|
|
|
|
|
|
pushd "$VSCODE_SRC_PATH/extensions/"
|
2024-10-18 12:31:28 +08:00
|
|
|
cp package-lock.json package-lock.json.temp
|
2022-08-23 05:07:57 +08:00
|
|
|
npm shrinkwrap
|
2024-10-18 12:31:28 +08:00
|
|
|
mv package-lock.json.temp package-lock.json
|
|
|
|
popd
|
2022-08-23 05:07:57 +08:00
|
|
|
}
|
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
main "$@"
|