Skip to content

Commit 4e77874

Browse files
committed
Avoid packaging yarn.lock
Since the shrinkwrap is what we want everything to use.
1 parent acc50a5 commit 4e77874

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

ci/build/build-release.sh

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ bundle_code_server() {
5656
}
5757
EOF
5858
) > "$RELEASE_PATH/package.json"
59-
rsync yarn.lock "$RELEASE_PATH"
6059
mv npm-shrinkwrap.json "$RELEASE_PATH"
6160

6261
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
@@ -106,34 +105,41 @@ bundle_vscode() {
106105
}
107106

108107
create_shrinkwraps() {
109-
# yarn.lock or package-lock.json files (used to ensure deterministic versions of dependencies) are
110-
# not packaged when publishing to the NPM registry.
111-
# To ensure deterministic dependency versions (even when code-server is installed with NPM), we create
112-
# an npm-shrinkwrap.json file from the currently installed node_modules. This ensures the versions used
113-
# from development (that the yarn.lock guarantees) are also the ones installed by end-users.
114-
# These will include devDependencies, but those will be ignored when installing globally (for code-server), and
115-
# because we use --omit=dev when installing vscode.
116-
117-
# We first generate the shrinkwrap file for code-server itself - which is the current directory
118-
create_shrinkwrap_keeping_yarn_lock
108+
# yarn.lock or package-lock.json files (used to ensure deterministic versions
109+
# of dependencies) are not packaged when publishing to the NPM registry.
110+
111+
# To ensure deterministic dependency versions (even when code-server is
112+
# installed with NPM), we create an npm-shrinkwrap.json file from the
113+
# currently installed node_modules. This ensures the versions used from
114+
# development (that the yarn.lock guarantees) are also the ones installed by
115+
# end-users. These will include devDependencies, but those will be ignored
116+
# when installing globally (for code-server), and because we use --omit=dev
117+
# when installing vscode.
118+
119+
# We also remove the yarn.lock files once we have done this even though they
120+
# are ignored by NPM on publish because we use the artifact uploaded to CI
121+
# (which would still include the yarn.lock) to generate the standalone builds
122+
# and we want to make sure we are not using yarn accidentally.
123+
124+
# We first generate the shrinkwrap file for code-server itself---which is the
125+
# current directory.
126+
create_shrinkwrap
119127

120128
# Then the shrinkwrap files for the bundled VSCode
121129
pushd "$VSCODE_SRC_PATH/remote/"
122-
create_shrinkwrap_keeping_yarn_lock
130+
create_shrinkwrap
123131
popd
124132

125133
pushd "$VSCODE_SRC_PATH/extensions/"
126-
create_shrinkwrap_keeping_yarn_lock
134+
create_shrinkwrap
127135
popd
128136
}
129137

130-
create_shrinkwrap_keeping_yarn_lock() {
131-
# HACK@edvincent: Generating a shrinkwrap alters the yarn.lock which we don't want (with NPM URLs rather than the Yarn URLs)
132-
# But to generate a valid shrinkwrap, it has to exist... So we copy it to then restore it
133-
cp yarn.lock yarn.lock.temp
138+
create_shrinkwrap() {
134139
npm shrinkwrap
135-
cp yarn.lock.temp yarn.lock
136-
rm yarn.lock.temp
140+
# Note that npm shrinkwrap alters the yarn.lock, but we are not going to keep
141+
# it anyway.
142+
rm yarn.lock
137143
}
138144

139145
main "$@"

0 commit comments

Comments
 (0)