11#! /usr/bin/env bash
22set -euo pipefail
33
4- # This script requires code-server and vscode to be built with
5- # matching MINIFY.
6-
7- # RELEASE_PATH is the destination directory for the release from the root.
8- # Defaults to release
9- RELEASE_PATH=" ${RELEASE_PATH-release} "
10-
11- # STATIC controls whether node and node_modules are packaged into the release.
12- # Disabled by default.
13- STATIC=" ${STATIC-} "
4+ # This script requires code-server and vscode to be built with matching MINIFY.
145
156# MINIFY controls whether minified vscode is bundled and whether
167# any included node_modules are pruned for production.
178MINIFY=" ${MINIFY-true} "
189
19- VSCODE_SRC_PATH=" lib/vscode"
20-
21- VSCODE_OUT_PATH=" $RELEASE_PATH /lib/vscode"
22-
2310main () {
2411 cd " $( dirname " ${0} " ) /../.."
25- source ./ci/lib.sh
12+ source ./ci/build/lib.sh
13+
14+ VSCODE_SRC_PATH=" lib/vscode"
15+ VSCODE_OUT_PATH=" $RELEASE_PATH /lib/vscode"
2616
2717 mkdir -p " $RELEASE_PATH "
2818
@@ -32,20 +22,6 @@ main() {
3222 rsync README.md " $RELEASE_PATH "
3323 rsync LICENSE.txt " $RELEASE_PATH "
3424 rsync ./lib/vscode/ThirdPartyNotices.txt " $RELEASE_PATH "
35-
36- if [[ $STATIC ]]; then
37- rsync " $RELEASE_PATH /" " $RELEASE_PATH -static"
38- RELEASE_PATH+=-static
39- VSCODE_OUT_PATH=" $RELEASE_PATH /lib/vscode"
40-
41- bundle_node
42- else
43- rm -Rf " $VSCODE_OUT_PATH /extensions/node_modules"
44- fi
45- }
46-
47- rsync () {
48- command rsync -a --del " $@ "
4925}
5026
5127bundle_code_server () {
@@ -76,6 +52,7 @@ bundle_vscode() {
7652 mkdir -p " $VSCODE_OUT_PATH "
7753 rsync " $VSCODE_SRC_PATH /out-vscode${MINIFY+-min} /" " $VSCODE_OUT_PATH /out"
7854 rsync " $VSCODE_SRC_PATH /.build/extensions/" " $VSCODE_OUT_PATH /extensions"
55+ rm -Rf " $VSCODE_OUT_PATH /extensions/node_modules"
7956 rsync " $VSCODE_SRC_PATH /extensions/package.json" " $VSCODE_OUT_PATH /extensions"
8057 rsync " $VSCODE_SRC_PATH /extensions/yarn.lock" " $VSCODE_OUT_PATH /extensions"
8158 rsync " $VSCODE_SRC_PATH /extensions/postinstall.js" " $VSCODE_OUT_PATH /extensions"
10380 jq ' del(.scripts)' < " $VSCODE_SRC_PATH /package.json" > " $VSCODE_OUT_PATH /package.json"
10481}
10582
106- bundle_node () {
107- # We cannot find the path to node from $PATH because yarn shims a script to ensure
108- # we use the same version it's using so we instead run a script with yarn that
109- # will print the path to node.
110- local node_path
111- node_path=" $( yarn -s node <<< ' console.info(process.execPath)' ) "
112-
113- mkdir -p " $RELEASE_PATH /bin"
114- rsync ./ci/build/code-server.sh " $RELEASE_PATH /bin/code-server"
115- rsync " $node_path " " $RELEASE_PATH /lib/node"
116-
117- rsync node_modules " $RELEASE_PATH "
118- rsync " $VSCODE_SRC_PATH /node_modules" " $VSCODE_OUT_PATH "
119-
120- if [[ $MINIFY ]]; then
121- pushd " $RELEASE_PATH "
122- yarn --production
123- popd
124- fi
125- }
126-
12783main " $@ "
0 commit comments