Skip to content

Commit f34e336

Browse files
committed
Update .gitignore to allow build directory
1 parent 6f8618a commit f34e336

12 files changed

Lines changed: 517 additions & 11 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dist/
1717
downloads/
1818
eggs/
1919
.eggs/
20+
lib/
2021
lib64/
2122
parts/
2223
sdist/

.tekton/odh-workbench-codeserver-datascience-cpu-py312-ubi9-pull-request.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ spec:
5656
type: rpm
5757
- path: codeserver/ubi9-python-3.12/prefetch-input
5858
type: generic
59-
- path: codeserver/ubi9-python-3.12/prefetch-input/code-server
60-
type: npm
61-
- path: codeserver/ubi9-python-3.12/prefetch-input/code-server/lib/vscode
59+
- path: codeserver/ubi9-python-3.12/patches/code-server/
6260
type: npm
6361
- path: codeserver/ubi9-python-3.12/patches/code-server/test
6462
type: npm
63+
- path: codeserver/ubi9-python-3.12/patches/code-server/lib-vscode
64+
type: npm
65+
- path: codeserver/ubi9-python-3.12/patches/code-server/lib-vscode/extensions/emmet
66+
type: npm
6567
- path: codeserver/ubi9-python-3.12/prefetch-input/code-server/test/e2e/extensions/test-extension
6668
type: npm
6769
pipelineRef:

.tekton/odh-workbench-codeserver-datascience-cpu-py312-ubi9-push.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ spec:
5454
type: npm
5555
- path: codeserver/ubi9-python-3.12/patches/code-server/test
5656
type: npm
57-
- path: codeserver/ubi9-python-3.12/patches/code-server/lib/vscode
57+
- path: codeserver/ubi9-python-3.12/patches/code-server/lib-vscode
5858
type: npm
59-
- path: codeserver/ubi9-python-3.12/patches/code-server/lib/vscode/extensions/emmet
59+
- path: codeserver/ubi9-python-3.12/patches/code-server/lib-vscode/extensions/emmet
6060
type: npm
6161
- path: codeserver/ubi9-python-3.12/prefetch-input/code-server/test/e2e/extensions/test-extension
6262
type: npm

codeserver/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ COPY ${CODESERVER_SOURCE_CODE}/prefetch-input/code-server/ ${CODESERVER_SOURCE_P
7373
# Apply these patches in order make it build hermetically.
7474
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/test/package-lock.json ${CODESERVER_SOURCE_PREFETCH}/test/package-lock.json
7575
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/test/package.json ${CODESERVER_SOURCE_PREFETCH}/test/package.json
76-
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib/vscode/package-lock.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/package-lock.json
77-
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib/vscode/package.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/package.json
78-
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib/vscode/build/lib/fetch.js ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/build/lib/fetch.js
79-
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib/vscode/extensions/emmet/package.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/extensions/emmet/package.json
80-
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib/vscode/extensions/emmet/package-lock.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/extensions/emmet/package-lock.json
76+
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib-vscode/package-lock.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/package-lock.json
77+
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib-vscode/package.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/package.json
78+
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib-vscode/build-lib/fetch.js ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/build/lib/fetch.js
79+
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib-vscode/extensions/emmet/package.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/extensions/emmet/package.json
80+
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/lib-vscode/extensions/emmet/package-lock.json ${CODESERVER_SOURCE_PREFETCH}/lib/vscode/extensions/emmet/package-lock.json
8181
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/ci/dev/postinstall.sh ${CODESERVER_SOURCE_PREFETCH}/ci/dev/postinstall.sh
82-
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/ci/build/build-vscode.sh ${CODESERVER_SOURCE_PREFETCH}/ci/build/build-vscode.sh
82+
COPY ${CODESERVER_SOURCE_CODE}/patches/code-server/ci/build-scripts/build-vscode.sh ${CODESERVER_SOURCE_PREFETCH}/ci/build/build-vscode.sh
8383

8484
COPY ${CODESERVER_SOURCE_CODE}/patches/s390x.patch ${CODESERVER_SOURCE_PREFETCH}/
8585

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Once both code-server and VS Code have been built, use this script to copy
5+
# them into a single directory (./release), prepare the package.json and
6+
# product.json, and add shrinkwraps. This results in a generic NPM package that
7+
# we published to NPM and also use to compile platform-specific packages.
8+
9+
# MINIFY controls whether minified VS Code is bundled. It must match the value
10+
# used when VS Code was built.
11+
MINIFY="${MINIFY-true}"
12+
13+
# node_modules are not copied by default. Set KEEP_MODULES=1 to copy them.
14+
KEEP_MODULES="${KEEP_MODULES-0}"
15+
16+
main() {
17+
cd "$(dirname "${0}")/../.."
18+
19+
source ./ci/lib.sh
20+
21+
VSCODE_SRC_PATH="lib/vscode"
22+
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
23+
24+
create_shrinkwraps
25+
26+
mkdir -p "$RELEASE_PATH"
27+
28+
bundle_code_server
29+
bundle_vscode
30+
31+
rsync ./docs/README.md "$RELEASE_PATH"
32+
rsync LICENSE "$RELEASE_PATH"
33+
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
34+
}
35+
36+
bundle_code_server() {
37+
rsync out "$RELEASE_PATH"
38+
39+
# For source maps and images.
40+
mkdir -p "$RELEASE_PATH/src/browser"
41+
rsync src/browser/media/ "$RELEASE_PATH/src/browser/media"
42+
mkdir -p "$RELEASE_PATH/src/browser/pages"
43+
rsync src/browser/pages/*.html "$RELEASE_PATH/src/browser/pages"
44+
rsync src/browser/pages/*.css "$RELEASE_PATH/src/browser/pages"
45+
rsync src/browser/robots.txt "$RELEASE_PATH/src/browser"
46+
47+
# Adds the commit to package.json
48+
jq --slurp '(.[0] | del(.scripts,.jest,.devDependencies)) * .[1]' package.json <(
49+
cat << EOF
50+
{
51+
"commit": "$(git rev-parse HEAD)",
52+
"scripts": {
53+
"postinstall": "sh ./postinstall.sh"
54+
}
55+
}
56+
EOF
57+
) > "$RELEASE_PATH/package.json"
58+
mv npm-shrinkwrap.json "$RELEASE_PATH"
59+
60+
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
61+
62+
if [ "$KEEP_MODULES" = 1 ]; then
63+
rsync node_modules/ "$RELEASE_PATH/node_modules"
64+
fi
65+
}
66+
67+
bundle_vscode() {
68+
mkdir -p "$VSCODE_OUT_PATH"
69+
70+
local rsync_opts=()
71+
if [[ ${DEBUG-} = 1 ]]; then
72+
rsync_opts+=(-vh)
73+
fi
74+
75+
# Some extensions have a .gitignore which excludes their built source from the
76+
# npm package so exclude any .gitignore files.
77+
rsync_opts+=(--exclude .gitignore)
78+
79+
# Exclude Node as we will add it ourselves for the standalone and will not
80+
# need it for the npm package.
81+
rsync_opts+=(--exclude /node)
82+
83+
# Exclude Node modules.
84+
if [[ $KEEP_MODULES = 0 ]]; then
85+
rsync_opts+=(--exclude node_modules)
86+
fi
87+
88+
rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH"
89+
90+
# Merge the package.json for the web/remote server so we can include
91+
# dependencies, since we want to ship this via NPM.
92+
jq --slurp '.[0] * .[1]' \
93+
"$VSCODE_SRC_PATH/remote/package.json" \
94+
"$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged"
95+
mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json"
96+
cp "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
97+
98+
# Include global extension dependencies as well.
99+
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json"
100+
cp "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json"
101+
rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs"
102+
}
103+
104+
create_shrinkwraps() {
105+
# package-lock.json files (used to ensure deterministic versions of
106+
# dependencies) are not packaged when publishing to the NPM registry.
107+
#
108+
# To ensure deterministic dependency versions (even when code-server is
109+
# installed with NPM), we create an npm-shrinkwrap.json file from the
110+
# currently installed node_modules. This ensures the versions used from
111+
# development (that the package-lock.json guarantees) are also the ones
112+
# installed by end-users. These will include devDependencies, but those will
113+
# be ignored when installing globally (for code-server), and because we use
114+
# --omit=dev (for VS Code).
115+
116+
# We first generate the shrinkwrap file for code-server itself - which is the
117+
# current directory.
118+
cp package-lock.json package-lock.json.temp
119+
npm shrinkwrap
120+
mv package-lock.json.temp package-lock.json
121+
122+
# Then the shrinkwrap files for the bundled VS Code.
123+
pushd "$VSCODE_SRC_PATH/remote/"
124+
cp package-lock.json package-lock.json.temp
125+
npm shrinkwrap
126+
mv package-lock.json.temp package-lock.json
127+
popd
128+
129+
pushd "$VSCODE_SRC_PATH/extensions/"
130+
cp package-lock.json package-lock.json.temp
131+
npm shrinkwrap
132+
mv package-lock.json.temp package-lock.json
133+
popd
134+
}
135+
136+
main "$@"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Once we have an NPM package, use this script to copy it to a separate
5+
# directory (./release-standalone) and install the dependencies. This new
6+
# directory can then be packaged as a platform-specific release.
7+
8+
main() {
9+
cd "$(dirname "${0}")/../.."
10+
11+
source ./ci/lib.sh
12+
13+
rsync "$RELEASE_PATH/" "$RELEASE_PATH-standalone"
14+
RELEASE_PATH+=-standalone
15+
16+
# Package managers may shim their own "node" wrapper into the PATH, so run
17+
# node and ask it for its true path.
18+
local node_path
19+
node_path="$(node -p process.execPath)"
20+
21+
mkdir -p "$RELEASE_PATH/bin"
22+
mkdir -p "$RELEASE_PATH/lib"
23+
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
24+
rsync "$node_path" "$RELEASE_PATH/lib/node"
25+
26+
chmod 755 "$RELEASE_PATH/lib/node"
27+
28+
pushd "$RELEASE_PATH"
29+
npm install --unsafe-perm --omit=dev
30+
# Code deletes some files from the extension node_modules directory which
31+
# leaves broken symlinks in the corresponding .bin directory. nfpm will fail
32+
# on these broken symlinks so clean them up.
33+
rm -fr "./lib/vscode/extensions/node_modules/.bin"
34+
popd
35+
}
36+
37+
main "$@"
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Builds vscode into lib/vscode/out-vscode.
5+
6+
# MINIFY controls whether a minified version of vscode is built.
7+
MINIFY=${MINIFY-true}
8+
9+
delete-bin-script() {
10+
rm -f "lib/vscode-reh-web-linux-x64/bin/$1"
11+
}
12+
13+
copy-bin-script() {
14+
local script="$1"
15+
local dest="lib/vscode-reh-web-linux-x64/bin/$script"
16+
cp "lib/vscode/resources/server/bin/$script" "$dest"
17+
sed -i.bak "s/@@VERSION@@/$(vscode_version)/g" "$dest"
18+
sed -i.bak "s/@@COMMIT@@/$BUILD_SOURCEVERSION/g" "$dest"
19+
sed -i.bak "s/@@APPNAME@@/code-server/g" "$dest"
20+
21+
# Fix Node path on Darwin and Linux.
22+
# We do not want expansion here; this text should make it to the file as-is.
23+
# shellcheck disable=SC2016
24+
sed -i.bak 's/^ROOT=\(.*\)$/VSROOT=\1\nROOT="$(dirname "$(dirname "$VSROOT")")"/g' "$dest"
25+
sed -i.bak 's/ROOT\/out/VSROOT\/out/g' "$dest"
26+
# We do not want expansion here; this text should make it to the file as-is.
27+
# shellcheck disable=SC2016
28+
sed -i.bak 's/$ROOT\/node/${NODE_EXEC_PATH:-$ROOT\/lib\/node}/g' "$dest"
29+
30+
# Fix Node path on Windows.
31+
sed -i.bak 's/^set ROOT_DIR=\(.*\)$/set ROOT_DIR=%~dp0..\\..\\..\\..\r\nset VSROOT_DIR=\1/g' "$dest"
32+
sed -i.bak 's/%ROOT_DIR%\\out/%VSROOT_DIR%\\out/g' "$dest"
33+
34+
chmod +x "$dest"
35+
rm "$dest.bak"
36+
}
37+
38+
main() {
39+
cd "$(dirname "${0}")/../.."
40+
41+
source ./ci/lib.sh
42+
43+
# Set the commit Code will embed into the product.json. We need to do this
44+
# since Code tries to get the commit from the `.git` directory which will fail
45+
# as it is a submodule.
46+
#
47+
# Also, we use code-server's commit rather than VS Code's otherwise it would
48+
# not update when only our patch files change, and that will cause caching
49+
# issues where the browser keeps using outdated code.
50+
export BUILD_SOURCEVERSION
51+
BUILD_SOURCEVERSION=$(git rev-parse HEAD)
52+
53+
pushd lib/vscode
54+
55+
if [[ ! ${VERSION-} ]]; then
56+
echo "VERSION not set. Please set before running this script:"
57+
echo "VERSION='0.0.0' npm run build:vscode"
58+
exit 1
59+
fi
60+
61+
# Add the date, our name, links, enable telemetry (this just makes telemetry
62+
# available; telemetry can still be disabled by flag or setting), and
63+
# configure trusted extensions (since some, like github.copilot-chat, never
64+
# ask to be trusted and this is the only way to get auth working).
65+
#
66+
# This needs to be done before building as Code will read this file and embed
67+
# it into the client-side code.
68+
git checkout product.json # Reset in case the script exited early.
69+
cp product.json product.original.json # Since jq has no inline edit.
70+
jq --slurp '.[0] * .[1]' product.original.json <(
71+
cat << EOF
72+
{
73+
"enableTelemetry": true,
74+
"quality": "stable",
75+
"codeServerVersion": "$VERSION",
76+
"nameShort": "code-server",
77+
"nameLong": "code-server",
78+
"applicationName": "code-server",
79+
"dataFolderName": ".code-server",
80+
"win32MutexName": "codeserver",
81+
"licenseUrl": "https://github.com/coder/code-server/blob/main/LICENSE",
82+
"win32DirName": "code-server",
83+
"win32NameVersion": "code-server",
84+
"win32AppUserModelId": "coder.code-server",
85+
"win32ShellNameShort": "c&ode-server",
86+
"darwinBundleIdentifier": "com.coder.code.server",
87+
"linuxIconName": "com.coder.code.server",
88+
"reportIssueUrl": "https://github.com/coder/code-server/issues/new",
89+
"documentationUrl": "https://go.microsoft.com/fwlink/?LinkID=533484#vscode",
90+
"keyboardShortcutsUrlMac": "https://go.microsoft.com/fwlink/?linkid=832143",
91+
"keyboardShortcutsUrlLinux": "https://go.microsoft.com/fwlink/?linkid=832144",
92+
"keyboardShortcutsUrlWin": "https://go.microsoft.com/fwlink/?linkid=832145",
93+
"introductoryVideosUrl": "https://go.microsoft.com/fwlink/?linkid=832146",
94+
"tipsAndTricksUrl": "https://go.microsoft.com/fwlink/?linkid=852118",
95+
"newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter",
96+
"linkProtectionTrustedDomains": [
97+
"https://open-vsx.org"
98+
],
99+
"trustedExtensionAuthAccess": [
100+
"vscode.git", "vscode.github",
101+
"github.vscode-pull-request-github",
102+
"github.copilot", "github.copilot-chat"
103+
],
104+
"aiConfig": {
105+
"ariaKey": "code-server"
106+
}
107+
}
108+
EOF
109+
) > product.json
110+
111+
# Any platform here works since we will do our own packaging. We have to do
112+
# this because we have an NPM package that could be installed on any platform.
113+
# The correct platform dependencies and scripts will be installed as part of
114+
# the post-install during `npm install` or when building a standalone release.
115+
node --max-old-space-size=16384 --optimize-for-size \
116+
./node_modules/gulp/bin/gulp.js \
117+
"vscode-reh-web-linux-x64${MINIFY:+-min}"
118+
119+
# Reset so if you develop after building you will not be stuck with the wrong
120+
# commit (the dev client will use `oss-dev` but the dev server will still use
121+
# product.json which will have `stable-$commit`).
122+
git checkout product.json
123+
124+
popd
125+
126+
pushd lib/vscode-reh-web-linux-x64
127+
# Make sure Code took the version we set in the environment variable. Not
128+
# having a version will break display languages.
129+
if ! jq -e .commit product.json; then
130+
echo "'commit' is missing from product.json"
131+
exit 1
132+
fi
133+
popd
134+
135+
# These provide a `code-server` command in the integrated terminal to open
136+
# files in the current instance.
137+
delete-bin-script remote-cli/code-server
138+
copy-bin-script remote-cli/code-darwin.sh
139+
copy-bin-script remote-cli/code-linux.sh
140+
copy-bin-script remote-cli/code.cmd
141+
142+
# These provide a way for terminal applications to open browser windows.
143+
delete-bin-script helpers/browser.sh
144+
copy-bin-script helpers/browser-darwin.sh
145+
copy-bin-script helpers/browser-linux.sh
146+
copy-bin-script helpers/browser.cmd
147+
}
148+
149+
main "$@"

0 commit comments

Comments
 (0)