@@ -2,33 +2,79 @@ const process = require("process");
2
2
const child_process = require ( "child_process" ) ;
3
3
const fs = require ( "fs" ) ;
4
4
const fse = require ( "fs-extra" ) ;
5
+ const { version } = require ( "./package.json" ) ;
5
6
6
- const vscodeVersion = "1.84.2" ;
7
+ const vscodeVersion = version . split ( "-" ) [ 0 ] ;
8
+
9
+ function error ( msg ) {
10
+ console . info ( "\x1b[31merror %s\x1b[0m" , msg )
11
+ }
12
+ function ok ( msg ) {
13
+ console . info ( "\x1b[32m%s\x1b[0m" , msg )
14
+ }
15
+ function note ( msg ) {
16
+ console . info ( "\x1b[90m%s\x1b[0m" , msg )
17
+ }
18
+ function exec ( cmd , opts ) {
19
+ console . info ( "\x1b[36m%s\x1b[0m" , cmd )
20
+ return child_process . execSync ( cmd , opts ) ;
21
+ }
22
+
23
+ const requiredTools = [ "node" , "yarn" , "git" , "python" ] ;
24
+ note ( `required tools ${ JSON . stringify ( requiredTools ) } ` )
25
+ for ( const tool of requiredTools ) {
26
+ try {
27
+ child_process . execSync ( `${ tool } --version` , { stdio : "ignore" } ) ;
28
+ } catch ( e ) {
29
+ error ( `"${ tool } " is not available.` ) ;
30
+ process . exit ( 1 ) ;
31
+ }
32
+ }
33
+ ok ( "required tools installed" )
34
+
35
+ const node_version_out = child_process . execSync ( `node -v` ) ;
36
+ const node_version = node_version_out . toString ( ) . trim ( )
37
+ if ( node_version < "v20.0" ) {
38
+ error ( `Want node > 20. Got "${ node_version } "` ) ;
39
+ process . exit ( 1 ) ;
40
+ }
7
41
8
42
if ( ! fs . existsSync ( "vscode" ) ) {
9
- child_process . execSync ( `git clone --depth 1 https://github.com/microsoft/vscode.git -b ${ vscodeVersion } ` , {
43
+ note ( "cloning vscode" )
44
+ exec ( `git clone --depth 1 https://github.com/microsoft/vscode.git -b ${ vscodeVersion } ` , {
10
45
stdio : "inherit" ,
11
46
} ) ;
47
+ } else {
48
+ ok ( "vscode already installed" )
49
+ note ( "delete vscode folder to clone again" )
12
50
}
51
+
52
+ note ( "changing directory to vscode" )
13
53
process . chdir ( "vscode" ) ;
14
54
15
55
if ( ! fs . existsSync ( "node_modules" ) ) {
16
- child_process . execSync ( "yarn" , { stdio : "inherit" } ) ;
56
+ exec ( "yarn" , { stdio : "inherit" } ) ;
57
+ } else {
58
+ ok ( "node_modules exists. Skipping yarn" )
17
59
}
60
+
18
61
// Use simple workbench
19
- fs . copyFileSync (
20
- "../workbench.ts" ,
21
- "src/vs/code/browser/workbench/workbench.ts"
22
- ) ;
62
+ note ( "copying workbench file" )
63
+ fs . copyFileSync ( "../workbench.ts" , "src/vs/code/browser/workbench/workbench.ts" ) ;
23
64
24
65
// Compile
25
- child_process . execSync ( "yarn gulp vscode-web-min" , { stdio : "inherit" } ) ;
66
+ note ( "starting compile" )
67
+ exec ( "yarn gulp vscode-web-min" , { stdio : "inherit" } ) ;
68
+ ok ( "compile completed" )
26
69
27
70
// Extract compiled files
28
71
if ( fs . existsSync ( "../dist" ) ) {
72
+ note ( "cleaning ../dist" )
29
73
fs . rmdirSync ( "../dist" , { recursive : true } ) ;
74
+ } else {
75
+ ok ( "../dist did not exist. No need to clean" )
30
76
}
77
+
31
78
fs . mkdirSync ( "../dist" ) ;
32
79
fse . copySync ( "../vscode-web" , "../dist" ) ;
33
-
34
-
80
+ ok ( "copied ../vscode-web to ../dist" )
0 commit comments