Skip to content

Commit 0323abb

Browse files
committed
fix: Generate shrinkwraps for the bundled vscode
1 parent 5bc26e9 commit 0323abb

File tree

5 files changed

+63
-167
lines changed

5 files changed

+63
-167
lines changed

.github/workflows/ci.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ jobs:
110110
fetch-depth: 0
111111
submodules: true
112112

113+
- name: Install development tools
114+
run: sudo apt install -y build-essential pkg-config g++ libx11-dev libxkbfile-dev libsecret-1-dev
115+
113116
- name: Install quilt
114117
run: sudo apt update && sudo apt install quilt
115118

@@ -183,6 +186,21 @@ jobs:
183186
name: npm-package
184187
path: ./package.tar.gz
185188

189+
# The npm artifact contains all the dependencies from node_modules,
190+
# and things like yarn.lock - and doesn't need to be installed.
191+
# This tarball is exactly what will be published to NPM.
192+
- name: Create npm release tarball
193+
run: |
194+
cd release
195+
yarn pack
196+
mv code-server*.tgz code-server-npm-dist-tarball.tgz
197+
198+
- name: Upload npm release tarball
199+
uses: actions/upload-artifact@v3
200+
with:
201+
name: code-server-npm-dist-tarball
202+
path: ./release/code-server-npm-dist-tarball.tgz
203+
186204
npm:
187205
# the npm-package gets uploaded as an artifact in Build
188206
# so we need that to complete before this runs

ci/build/build-release.sh

+30-10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ main() {
2323
bundle_code_server
2424
bundle_vscode
2525

26+
create_shrinkwraps
27+
2628
rsync ./docs/README.md "$RELEASE_PATH"
2729
rsync LICENSE.txt "$RELEASE_PATH"
2830
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
@@ -56,16 +58,6 @@ EOF
5658
) > "$RELEASE_PATH/package.json"
5759
rsync yarn.lock "$RELEASE_PATH"
5860

59-
# To ensure deterministic dependency versions (even when code-server is installed with NPM), we seed
60-
# an npm-shrinkwrap file from our yarn lockfile and the current node-modules installed.
61-
synp --source-file yarn.lock
62-
npm shrinkwrap
63-
# HACK@edvincent: The shrinkwrap file will contain the devDependencies, which by default
64-
# are installed if present in a lockfile. To avoid every user having to specify --production
65-
# to skip them, we carefully remove them from the shrinkwrap file.
66-
json -f npm-shrinkwrap.json -I -e "Object.keys(this.dependencies).forEach(dependency => { if (this.dependencies[dependency].dev) { delete this.dependencies[dependency] } } )"
67-
mv npm-shrinkwrap.json "$RELEASE_PATH"
68-
6961
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
7062

7163
if [ "$KEEP_MODULES" = 1 ]; then
@@ -153,4 +145,32 @@ EOF
153145
popd
154146
}
155147

148+
create_shrinkwraps() {
149+
# yarn.lock or package-lock.json files (used to ensure deterministic versions of dependencies) are
150+
# not packaged when publishing to the NPM registry.
151+
# To ensure deterministic dependency versions (even when code-server is installed with NPM), we create
152+
# an npm-shrinkwrap.json file from the currently installed node_modules. This ensures the versions used
153+
# from development (that the yarn.lock guarantees) are also the ones installed by end-users.
154+
155+
# We first generate the shrinkwrap file for code-server itself
156+
npm shrinkwrap
157+
# HACK@edvincent: The shrinkwrap file will contain the devDependencies, which by default
158+
# are installed if present in a lockfile. To avoid every user having to specify --production
159+
# to skip them, we carefully remove them from the shrinkwrap file.
160+
json -f npm-shrinkwrap.json -I -e "Object.keys(this.dependencies).forEach(dependency => { if (this.dependencies[dependency].dev) { delete this.dependencies[dependency] } } )"
161+
mv npm-shrinkwrap.json "$RELEASE_PATH"
162+
163+
# Then the shrinkwrap files for the bundled VSCode
164+
# We don't need to remove the devDependencies for these because we control how it's installed - and
165+
# as such we can force the --production flag
166+
cd lib/vscode/
167+
npm shrinkwrap
168+
169+
cd extensions/
170+
npm shrinkwrap
171+
172+
cd ../../..
173+
mv lib/vscode/npm-shrinkwrap.json "$RELEASE_PATH/lib/vscode/npm-shrinkwrap.json"
174+
mv lib/vscode/extensions/npm-shrinkwrap.json "$RELEASE_PATH/lib/vscode/extensions/npm-shrinkwrap.json"
175+
}
156176
main "$@"

ci/build/npm-postinstall.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,18 @@ symlink_asar() {
9090
}
9191

9292
vscode_yarn() {
93+
# NOTE@edvincent: Ideally, this should use `npm ci --production` - which is the equivalent of a
94+
# frozen lockfile. NPM 6 doesn't deal well with `npm ci` and optionalDependencies (tries to install them
95+
# anyway) - which are used for some Windows-only packages - so until we can upgrade to a higher version
96+
# of NPM (along with Node), we rely on NPM's behavior to prefer what's on the lockfile and resolve what isn't.
9397
echo 'Installing Code dependencies...'
9498
cd lib/vscode
95-
yarn --production --frozen-lockfile
99+
npm install --production
96100

97101
symlink_asar
98102

99103
cd extensions
100-
yarn --production --frozen-lockfile
104+
npm install --production
101105
}
102106

103107
main "$@"

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@
6060
"eslint-plugin-import": "^2.18.2",
6161
"eslint-plugin-prettier": "^4.0.0",
6262
"json": "^11.0.0",
63+
"minimist": "npm:minimist-lite@2.2.1",
64+
"normalize-package-data": "^4.0.0",
65+
"postcss": "^8.2.1",
6366
"prettier": "^2.2.1",
6467
"prettier-plugin-sh": "^0.8.0",
6568
"shellcheck": "^1.0.0",
6669
"stylelint": "^13.0.0",
6770
"stylelint-config-recommended": "^5.0.0",
68-
"synp": "^1.9.10",
71+
"trim": "^1.0.0",
6972
"ts-node": "^10.0.0",
70-
"typescript": "^4.4.0-dev.20210528"
73+
"typescript": "^4.4.0-dev.20210528",
74+
"underscore": "^1.13.1"
7175
},
7276
"resolutions": {
7377
"ansi-regex": "^5.0.1",
@@ -106,8 +110,7 @@
106110
"semver": "^7.1.3",
107111
"split2": "^4.0.0",
108112
"ws": "^8.0.0",
109-
"xdg-basedir": "^4.0.0",
110-
"yarn": "^1.22.4"
113+
"xdg-basedir": "^4.0.0"
111114
},
112115
"bin": {
113116
"code-server": "out/node/entry.js"

0 commit comments

Comments
 (0)