@@ -10,6 +10,7 @@ const libPath = path.join(__dirname, "../lib");
10
10
const vscodePath = path . join ( libPath , "vscode" ) ;
11
11
const pkgsPath = path . join ( __dirname , "../packages" ) ;
12
12
const defaultExtensionsPath = path . join ( libPath , "VSCode-linux-x64/resources/app/extensions" ) ;
13
+ const vscodeVersion = "1.32" ;
13
14
14
15
const buildServerBinary = register ( "build:server:binary" , async ( runner ) => {
15
16
await ensureInstalled ( ) ;
@@ -40,22 +41,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async (
40
41
} ) ;
41
42
42
43
const dependencyNexeBinary = register ( "dependency:nexe" , async ( runner ) => {
43
- if ( os . platform ( ) === "linux" ) {
44
+ if ( os . platform ( ) === "linux" && process . env . COMPRESS === "true" ) {
45
+ // Download the nexe binary so we can compress it before nexe runs. If we
46
+ // don't want compression we don't need to do anything since nexe will take
47
+ // care of getting the binary.
44
48
const nexeDir = path . join ( os . homedir ( ) , ".nexe" ) ;
45
49
const targetBinaryName = `${ os . platform ( ) } -${ os . arch ( ) } -${ process . version . substr ( 1 ) } ` ;
46
50
const targetBinaryPath = path . join ( nexeDir , targetBinaryName ) ;
47
51
if ( ! fs . existsSync ( targetBinaryPath ) ) {
48
- /**
49
- * We create a binary with nexe
50
- * so we can compress it
51
- */
52
52
fse . mkdirpSync ( nexeDir ) ;
53
53
runner . cwd = nexeDir ;
54
54
await runner . execute ( "wget" , [ `https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${ targetBinaryName } ` ] ) ;
55
55
await runner . execute ( "chmod" , [ "+x" , targetBinaryPath ] ) ;
56
56
}
57
+ // Compress with upx if it doesn't already look compressed.
57
58
if ( fs . statSync ( targetBinaryPath ) . size >= 20000000 ) {
58
- // Compress w/ upx
59
+ // It needs to be executable for upx to work, which it might not be if
60
+ // nexe downloaded it.
61
+ fs . chmodSync ( targetBinaryPath , "755" ) ;
59
62
const upxFolder = path . join ( os . tmpdir ( ) , "upx" ) ;
60
63
const upxBinary = path . join ( upxFolder , "upx" ) ;
61
64
if ( ! fs . existsSync ( upxBinary ) ) {
@@ -194,7 +197,7 @@ const buildDefaultExtensions = register("build:default-extensions", async (runne
194
197
if ( ! fs . existsSync ( defaultExtensionsPath ) ) {
195
198
await copyForDefaultExtensions ( ) ;
196
199
runner . cwd = extDirPath ;
197
- const resp = await runner . execute ( isWin ? "npx.cmd" : "npx" , [ isWin ? "gulp.cmd" : "gulp" , "vscode-linux-x64" ] ) ;
200
+ const resp = await runner . execute ( isWin ? "npx.cmd" : "npx" , [ isWin ? "gulp.cmd" : "gulp" , "vscode-linux-x64" , "--max-old-space-size=32384" ] ) ;
198
201
if ( resp . exitCode !== 0 ) {
199
202
throw new Error ( `Failed to build default extensions: ${ resp . stderr } ` ) ;
200
203
}
@@ -217,17 +220,11 @@ const ensureCloned = register("vscode:clone", async (runner) => {
217
220
} else {
218
221
fse . mkdirpSync ( libPath ) ;
219
222
runner . cwd = libPath ;
220
- const clone = await runner . execute ( "git" , [ "clone" , "https://github.com/microsoft/vscode" ] ) ;
223
+ const clone = await runner . execute ( "git" , [ "clone" , "https://github.com/microsoft/vscode" , "--branch" , `release/ ${ vscodeVersion } ` , "--single-branch" , "--depth=1" ] ) ;
221
224
if ( clone . exitCode !== 0 ) {
222
225
throw new Error ( `Failed to clone: ${ clone . exitCode } ` ) ;
223
226
}
224
227
}
225
-
226
- runner . cwd = vscodePath ;
227
- const checkout = await runner . execute ( "git" , [ "checkout" , "tags/1.31.0" ] ) ;
228
- if ( checkout . exitCode !== 0 ) {
229
- throw new Error ( `Failed to checkout: ${ checkout . stderr } ` ) ;
230
- }
231
228
} ) ;
232
229
233
230
const ensureClean = register ( "vscode:clean" , async ( runner ) => {
@@ -244,6 +241,10 @@ const ensureClean = register("vscode:clean", async (runner) => {
244
241
throw new Error ( `Failed to remove unstaged files: ${ removeUnstaged . stderr } ` ) ;
245
242
}
246
243
}
244
+ const fetch = await runner . execute ( "git" , [ "fetch" , "--prune" ] ) ;
245
+ if ( fetch . exitCode !== 0 ) {
246
+ throw new Error ( `Failed to fetch latest changes: ${ fetch . stderr } ` ) ;
247
+ }
247
248
} ) ;
248
249
249
250
const ensurePatched = register ( "vscode:patch" , async ( runner ) => {
@@ -260,4 +261,30 @@ const ensurePatched = register("vscode:patch", async (runner) => {
260
261
}
261
262
} ) ;
262
263
264
+ register ( "package" , async ( runner , releaseTag ) => {
265
+ if ( ! releaseTag ) {
266
+ throw new Error ( "Please specify the release tag." ) ;
267
+ }
268
+
269
+ const releasePath = path . resolve ( __dirname , "../release" ) ;
270
+
271
+ const archiveName = `code-server-${ releaseTag } -${ os . platform ( ) } -${ os . arch ( ) } ` ;
272
+ const archiveDir = path . join ( releasePath , archiveName ) ;
273
+ fse . removeSync ( archiveDir ) ;
274
+ fse . mkdirpSync ( archiveDir ) ;
275
+
276
+ const binaryPath = path . join ( __dirname , `../packages/server/cli-${ os . platform ( ) } -${ os . arch ( ) } ` ) ;
277
+ const binaryDestination = path . join ( archiveDir , "code-server" ) ;
278
+ fse . copySync ( binaryPath , binaryDestination ) ;
279
+ fs . chmodSync ( binaryDestination , "755" ) ;
280
+ [ "README.md" , "LICENSE" ] . forEach ( ( fileName ) => {
281
+ fse . copySync ( path . resolve ( __dirname , `../${ fileName } ` ) , path . join ( archiveDir , fileName ) ) ;
282
+ } ) ;
283
+
284
+ runner . cwd = releasePath ;
285
+ await os . platform ( ) === "linux"
286
+ ? runner . execute ( "tar" , [ "-cvzf" , `${ archiveName } .tar.gz` , `${ archiveName } ` ] )
287
+ : runner . execute ( "zip" , [ "-r" , `${ archiveName } .zip` , `${ archiveName } ` ] ) ;
288
+ } ) ;
289
+
263
290
run ( ) ;
0 commit comments