@@ -18,6 +18,8 @@ main() {
18
18
VSCODE_SRC_PATH=" lib/vscode"
19
19
VSCODE_OUT_PATH=" $RELEASE_PATH /lib/vscode"
20
20
21
+ create_shrinkwraps
22
+
21
23
mkdir -p " $RELEASE_PATH "
22
24
23
25
bundle_code_server
@@ -55,15 +57,6 @@ bundle_code_server() {
55
57
EOF
56
58
) > " $RELEASE_PATH /package.json"
57
59
rsync yarn.lock " $RELEASE_PATH "
58
-
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
60
mv npm-shrinkwrap.json " $RELEASE_PATH "
68
61
69
62
rsync ci/build/npm-postinstall.sh " $RELEASE_PATH /postinstall.sh"
@@ -105,11 +98,44 @@ bundle_vscode() {
105
98
" $VSCODE_SRC_PATH /package.json" > " $VSCODE_OUT_PATH /package.json"
106
99
107
100
rsync " $VSCODE_SRC_PATH /remote/yarn.lock" " $VSCODE_OUT_PATH /yarn.lock"
101
+ mv " $VSCODE_SRC_PATH /remote/npm-shrinkwrap.json" " $VSCODE_OUT_PATH /npm-shrinkwrap.json"
108
102
109
103
# Include global extension dependencies as well.
110
104
rsync " $VSCODE_SRC_PATH /extensions/package.json" " $VSCODE_OUT_PATH /extensions/package.json"
111
105
rsync " $VSCODE_SRC_PATH /extensions/yarn.lock" " $VSCODE_OUT_PATH /extensions/yarn.lock"
106
+ mv " $VSCODE_SRC_PATH /extensions/npm-shrinkwrap.json" " $VSCODE_OUT_PATH /extensions/npm-shrinkwrap.json"
112
107
rsync " $VSCODE_SRC_PATH /extensions/postinstall.mjs" " $VSCODE_OUT_PATH /extensions/postinstall.mjs"
113
108
}
114
109
110
+ create_shrinkwraps () {
111
+ # yarn.lock or package-lock.json files (used to ensure deterministic versions of dependencies) are
112
+ # not packaged when publishing to the NPM registry.
113
+ # To ensure deterministic dependency versions (even when code-server is installed with NPM), we create
114
+ # an npm-shrinkwrap.json file from the currently installed node_modules. This ensures the versions used
115
+ # from development (that the yarn.lock guarantees) are also the ones installed by end-users.
116
+ # These will include devDependencies, but those will be ignored when installing globally (for code-server), and
117
+ # because we use --omit=dev when installing vscode.
118
+
119
+ # We first generate the shrinkwrap file for code-server itself - which is the current directory
120
+ create_shrinkwrap_keeping_yarn_lock
121
+
122
+ # Then the shrinkwrap files for the bundled VSCode
123
+ pushd " $VSCODE_SRC_PATH /remote/"
124
+ create_shrinkwrap_keeping_yarn_lock
125
+ popd
126
+
127
+ pushd " $VSCODE_SRC_PATH /extensions/"
128
+ create_shrinkwrap_keeping_yarn_lock
129
+ popd
130
+ }
131
+
132
+ create_shrinkwrap_keeping_yarn_lock () {
133
+ # HACK@edvincent: Generating a shrinkwrap alters the yarn.lock which we don't want (with NPM URLs rather than the Yarn URLs)
134
+ # But to generate a valid shrinkwrap, it has to exist... So we copy it to then restore it
135
+ cp yarn.lock yarn.lock.temp
136
+ npm shrinkwrap
137
+ cp yarn.lock.temp yarn.lock
138
+ rm yarn.lock.temp
139
+ }
140
+
115
141
main " $@ "
0 commit comments