Skip to content

Commit f885b29

Browse files
GirlBossRushTeffen Ellis
authored and
Teffen Ellis
committed
Add vscode via vendor package.
- Use yarn for vscode vendoring. - Grab hash from package.
1 parent 28ba59a commit f885b29

32 files changed

+1546
-253
lines changed

.github/codeql-config.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
name: "code-server CodeQL config"
2-
3-
paths-ignore:
4-
- lib/vscode

.github/workflows/ci.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,26 @@ jobs:
124124
- name: Build code-server
125125
run: yarn build
126126

127-
# Parse the hash of the latest commit inside lib/vscode
127+
# Parse the hash of the latest commit inside vendor/modules/code-oss-dev
128128
# use this to avoid rebuilding it if nothing changed
129129
# How it works: the `git log` command fetches the hash of the last commit
130-
# that changed a file inside `lib/vscode`. If a commit changes any file in there,
130+
# that changed a file inside `vendor/modules/code-oss-dev`. If a commit changes any file in there,
131131
# the hash returned will change, and we rebuild vscode. If the hash did not change,
132132
# (for example, a change to `src/` or `docs/`), we reuse the same build as last time.
133133
# This saves a lot of time in CI, as compiling VSCode can take anywhere from 5-10 minutes.
134-
- name: Get latest lib/vscode rev
134+
- name: Get latest vendor/modules/code-oss-dev rev
135135
id: vscode-rev
136-
run: echo "::set-output name=rev::$(git log -1 --format='%H' ./lib/vscode)"
136+
run: echo "::set-output name=rev::$(jq -r '.devDependencies["code-oss-dev"]' vendor/package.json | sed -r 's|.*#(.*)$|\1|')"
137137

138138
- name: Attempt to fetch vscode build from cache
139139
id: cache-vscode
140140
uses: actions/cache@v2
141141
with:
142142
path: |
143-
lib/vscode/.build
144-
lib/vscode/out-build
145-
lib/vscode/out-vscode
146-
lib/vscode/out-vscode-min
143+
vendor/modules/code-oss-dev/.build
144+
vendor/modules/code-oss-dev/out-build
145+
vendor/modules/code-oss-dev/out-vscode
146+
vendor/modules/code-oss-dev/out-vscode-min
147147
key: vscode-build-${{ steps.vscode-rev.outputs.rev }}
148148

149149
- name: Build vscode

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ release-packages/
88
release-gcp/
99
release-images/
1010
node_modules
11-
/lib/vscode/node_modules.asar
11+
vendor/modules
1212
node-*
1313
/plugins
1414
/lib/coder-cloud-agent

.tours/contributing.tour

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@
143143
"description": "Static images and the manifest live here in `src/browser/media` (see the explorer)."
144144
},
145145
{
146-
"directory": "lib/vscode",
146+
"directory": "vendor/modules/code-oss-dev",
147147
"line": 1,
148148
"description": "code-server makes use of VS Code's frontend web/remote support. Most of the modifications implement the remote server since that portion of the code is closed source and not released with VS Code.\n\nWe also have a few bug fixes and have added some features (like client-side extensions). See [https://github.com/cdr/code-server/blob/master/docs/CONTRIBUTING.md#modifications-to-vs-code](https://github.com/cdr/code-server/blob/master/docs/CONTRIBUTING.md#modifications-to-vs-code) for a list.\n\nWe make an effort to keep the modifications as few as possible."
149149
}
150150
]
151-
}
151+
}

ci/build/build-release.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ KEEP_MODULES="${KEEP_MODULES-0}"
1212

1313
main() {
1414
cd "$(dirname "${0}")/../.."
15+
1516
source ./ci/lib.sh
1617

17-
VSCODE_SRC_PATH="lib/vscode"
18-
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
18+
VSCODE_SRC_PATH="vendor/modules/code-oss-dev"
19+
VSCODE_OUT_PATH="$RELEASE_PATH/vendor/modules/code-oss-dev"
1920

2021
mkdir -p "$RELEASE_PATH"
2122

@@ -24,7 +25,7 @@ main() {
2425

2526
rsync ./docs/README.md "$RELEASE_PATH"
2627
rsync LICENSE.txt "$RELEASE_PATH"
27-
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
28+
rsync ./vendor/modules/code-oss-dev/ThirdPartyNotices.txt "$RELEASE_PATH"
2829
}
2930

3031
bundle_code_server() {

ci/build/build-standalone-release.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export npm_config_build_from_source=true
77

88
main() {
99
cd "$(dirname "${0}")/../.."
10+
1011
source ./ci/lib.sh
1112

1213
rsync "$RELEASE_PATH/" "$RELEASE_PATH-standalone"
@@ -19,6 +20,7 @@ main() {
1920
node_path="$(yarn -s node <<< 'console.info(process.execPath)')"
2021

2122
mkdir -p "$RELEASE_PATH/bin"
23+
mkdir -p "$RELEASE_PATH/lib"
2224
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
2325
rsync "$node_path" "$RELEASE_PATH/lib/node"
2426

@@ -32,7 +34,7 @@ main() {
3234
# leaves a few stray symlinks. Clean them up so nfpm does not fail.
3335
# Remove this line when its no longer needed.
3436

35-
rm -fr "$RELEASE_PATH/lib/vscode/extensions/node_modules/.bin"
37+
rm -fr "$RELEASE_PATH/vendor/modules/code-oss-dev/extensions/node_modules/.bin"
3638
}
3739

3840
main "$@"

ci/build/build-vscode.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# Builds vscode into lib/vscode/out-vscode.
4+
# Builds vscode into vendor/modules/code-oss-dev/out-vscode.
55

66
# MINIFY controls whether a minified version of vscode is built.
77
MINIFY=${MINIFY-true}
88

99
main() {
1010
cd "$(dirname "${0}")/../.."
11-
cd lib/vscode
11+
12+
cd vendor/modules/code-oss-dev
1213

1314
yarn gulp compile-build compile-extensions-build compile-extension-media
1415
yarn gulp optimize --gulpfile ./coder.js

ci/build/clean.sh

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ main() {
66
source ./ci/lib.sh
77

88
git clean -Xffd
9-
10-
pushd lib/vscode
11-
git clean -xffd
12-
popd
139
}
1410

1511
main "$@"

ci/build/npm-postinstall.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ symlink_asar() {
8787
}
8888

8989
vscode_yarn() {
90-
cd lib/vscode
90+
echo 'Installing vendor dependencies...'
91+
cd vendor/modules/code-oss-dev
9192
yarn --production --frozen-lockfile
9293

9394
symlink_asar
9495

9596
cd extensions
9697
yarn --production --frozen-lockfile
98+
9799
for ext in */; do
98100
ext="${ext%/}"
99101
echo "extensions/$ext: installing dependencies"

ci/dev/fmt.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ main() {
1919
"*.sh"
2020
)
2121
prettier --write --loglevel=warn $(
22-
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v 'helm-chart'
22+
git ls-files "${prettierExts[@]}" | grep -v "lib/vscode" | grep -v "vendor/modules/code-oss-dev" | grep -v 'helm-chart'
2323
)
2424

2525
doctoc --title '# FAQ' docs/FAQ.md > /dev/null
@@ -32,6 +32,7 @@ main() {
3232
doctoc --title '# iPad' docs/ipad.md > /dev/null
3333
doctoc --title '# Termux' docs/termux.md > /dev/null
3434

35+
# TODO: replace with a method that generates fewer false positives.
3536
if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
3637
echo "Files need generation or are formatted incorrectly:"
3738
git -c color.ui=always status | grep --color=no '\[31m'

ci/dev/lint.sh

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ set -euo pipefail
44
main() {
55
cd "$(dirname "$0")/../.."
66

7-
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js" | grep -v "lib/vscode")
8-
stylelint $(git ls-files "*.css" | grep -v "lib/vscode")
7+
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js" | grep -v "vendor/modules/code-oss-dev" | grep -v "lib/vscode")
8+
stylelint $(git ls-files "*.css" | grep -v "vendor/modules/code-oss-dev" | grep -v "lib/vscode")
99
tsc --noEmit --skipLibCheck
10-
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh" | grep -v "lib/vscode")
10+
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh" | grep -v "vendor/modules/code-oss-dev" | grep -v "lib/vscode")
1111
if command -v helm && helm kubeval --help > /dev/null; then
1212
helm kubeval ci/helm-chart
1313
fi
1414

15-
cd lib/vscode
16-
# Run this periodically in vanilla VS code to make sure we don't add any more warnings.
17-
yarn -s eslint --max-warnings=3
1815
cd "$OLDPWD"
1916
}
2017

ci/dev/postinstall.sh

+17-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,28 @@ set -euo pipefail
33

44
main() {
55
cd "$(dirname "$0")/../.."
6-
source ./ci/lib.sh
76

8-
# This installs the dependencies needed for testing
7+
echo 'Installing code-server test dependencies...'
8+
99
cd test
10-
yarn
10+
yarn install
1111
cd ..
1212

13-
cd lib/vscode
14-
yarn ${CI+--frozen-lockfile}
13+
cd vendor
14+
echo 'Installing vendor dependencies...'
15+
16+
# * We install in 'modules' instead of 'node_modules' because VS Code's extensions
17+
# use a webpack config which cannot differentiate between its own node_modules
18+
# and itself being in a directory with the same name.
19+
#
20+
# * We ignore scripts because NPM/Yarn's default behavior is to assume that
21+
# devDependencies are not needed, and that even git repo based packages are
22+
# assumed to be compiled. Because the default behavior for VS Code's `postinstall`
23+
# assumes we're also compiled, this needs to be ignored.
24+
yarn install --modules-folder modules --ignore-scripts --frozen-lockfile
1525

16-
symlink_asar
26+
# Finally, run the vendor `postinstall`
27+
yarn run postinstall
1728
}
1829

1930
main "$@"

ci/dev/test-e2e.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -euo pipefail
33

44
main() {
55
cd "$(dirname "$0")/../.."
6+
67
source ./ci/lib.sh
78

89
local dir="$PWD"
@@ -24,7 +25,7 @@ main() {
2425
exit 1
2526
fi
2627

27-
if [[ ! -d $dir/lib/vscode/out ]]; then
28+
if [[ ! -d $dir/vendor/modules/code-oss-dev/out ]]; then
2829
echo >&2 "No VS Code build detected"
2930
echo >&2 "You can build it with 'yarn build:vscode' or 'yarn watch'"
3031
exit 1

ci/dev/update-vscode.sh

-133
This file was deleted.

ci/dev/watch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function main(): Promise<void> {
1616

1717
class Watcher {
1818
private readonly rootPath = path.resolve(__dirname, "../..")
19-
private readonly vscodeSourcePath = path.join(this.rootPath, "lib/vscode")
19+
private readonly vscodeSourcePath = path.join(this.rootPath, "vendor/modules/code-oss-dev")
2020

2121
private static log(message: string, skipNewline = false): void {
2222
process.stdout.write(message)

ci/lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pkg_json_version() {
1414
}
1515

1616
vscode_version() {
17-
jq -r .version lib/vscode/package.json
17+
jq -r .version vendor/modules/code-oss-dev/package.json
1818
}
1919

2020
os() {

0 commit comments

Comments
 (0)