@@ -11,6 +11,8 @@ const concat = require("gulp-concat");
11
11
const clone = require ( "gulp-clone" ) ;
12
12
const newer = require ( "gulp-newer" ) ;
13
13
const tsc = require ( "gulp-typescript" ) ;
14
+ const tsc_oop = require ( "./scripts/build/gulp-typescript-oop" ) ;
15
+ const getDirSize = require ( "./scripts/build/getDirSize" ) ;
14
16
const insert = require ( "gulp-insert" ) ;
15
17
const sourcemaps = require ( "gulp-sourcemaps" ) ;
16
18
const Q = require ( "q" ) ;
@@ -36,7 +38,7 @@ const constEnumCaptureRegexp = /^(\s*)(export )?const enum (\S+) {(\s*)$/gm;
36
38
const constEnumReplacement = "$1$2enum $3 {$4" ;
37
39
38
40
const cmdLineOptions = minimist ( process . argv . slice ( 2 ) , {
39
- boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" ] ,
41
+ boolean : [ "debug" , "inspect" , "light" , "colors" , "lint" , "soft" , "fix" ] ,
40
42
string : [ "browser" , "tests" , "host" , "reporter" , "stackTraceLimit" , "timeout" ] ,
41
43
alias : {
42
44
"b" : "browser" ,
@@ -47,6 +49,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
47
49
"r" : "reporter" ,
48
50
"c" : "colors" , "color" : "colors" ,
49
51
"w" : "workers" ,
52
+ "f" : "fix" ,
50
53
} ,
51
54
default : {
52
55
soft : false ,
@@ -61,6 +64,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
61
64
light : process . env . light === undefined || process . env . light !== "false" ,
62
65
reporter : process . env . reporter || process . env . r ,
63
66
lint : process . env . lint || true ,
67
+ fix : process . env . fix || process . env . f ,
64
68
workers : process . env . workerCount || os . cpus ( ) . length ,
65
69
}
66
70
} ) ;
@@ -260,6 +264,7 @@ function getCompilerSettings(base, useBuiltCompiler) {
260
264
for ( const key in base ) {
261
265
copy [ key ] = base [ key ] ;
262
266
}
267
+ copy . strictNullChecks = true ;
263
268
if ( ! useDebugMode ) {
264
269
if ( copy . removeComments === undefined ) copy . removeComments = true ;
265
270
}
@@ -409,6 +414,10 @@ function prependCopyright(outputCopyright = !useDebugMode) {
409
414
return insert . prepend ( outputCopyright ? ( copyrightContent || ( copyrightContent = fs . readFileSync ( copyright ) . toString ( ) ) ) : "" ) ;
410
415
}
411
416
417
+ function getCompilerPath ( useBuiltCompiler ) {
418
+ return useBuiltCompiler ? "./built/local/typescript.js" : "./lib/typescript.js" ;
419
+ }
420
+
412
421
gulp . task ( builtLocalCompiler , /*help*/ false , [ servicesFile ] , ( ) => {
413
422
const localCompilerProject = tsc . createProject ( "src/compiler/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
414
423
return localCompilerProject . src ( )
@@ -421,7 +430,7 @@ gulp.task(builtLocalCompiler, /*help*/ false, [servicesFile], () => {
421
430
} ) ;
422
431
423
432
gulp . task ( servicesFile , /*help*/ false , [ "lib" , "generate-diagnostics" ] , ( ) => {
424
- const servicesProject = tsc . createProject ( "src/services/tsconfig.json" , getCompilerSettings ( { removeComments : false } , /*useBuiltCompiler*/ false ) ) ;
433
+ const servicesProject = tsc_oop . createProject ( "src/services/tsconfig.json" , getCompilerSettings ( { removeComments : false } ) , { typescript : getCompilerPath ( /*useBuiltCompiler*/ false ) } ) ;
425
434
const { js, dts} = servicesProject . src ( )
426
435
. pipe ( newer ( servicesFile ) )
427
436
. pipe ( sourcemaps . init ( ) )
@@ -496,7 +505,7 @@ const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js")
496
505
const tsserverLibraryDefinitionFile = path . join ( builtLocalDirectory , "tsserverlibrary.d.ts" ) ;
497
506
498
507
gulp . task ( tsserverLibraryFile , /*help*/ false , [ servicesFile , typesMapJson ] , ( done ) => {
499
- const serverLibraryProject = tsc . createProject ( "src/server/tsconfig.library.json" , getCompilerSettings ( { removeComments : false } , /*useBuiltCompiler*/ true ) ) ;
508
+ const serverLibraryProject = tsc_oop . createProject ( "src/server/tsconfig.library.json" , getCompilerSettings ( { removeComments : false } ) , { typescript : getCompilerPath ( /*useBuiltCompiler*/ true ) } ) ;
500
509
/** @type {{ js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } } */
501
510
const { js, dts} = serverLibraryProject . src ( )
502
511
. pipe ( sourcemaps . init ( ) )
@@ -580,14 +589,20 @@ gulp.task("VerifyLKG", /*help*/ false, [], () => {
580
589
gulp . task ( "LKGInternal" , /*help*/ false , [ "lib" , "local" ] ) ;
581
590
582
591
gulp . task ( "LKG" , "Makes a new LKG out of the built js files" , [ "clean" , "dontUseDebugMode" ] , ( ) => {
583
- return runSequence ( "LKGInternal" , "VerifyLKG" ) ;
592
+ const sizeBefore = getDirSize ( lkgDirectory ) ;
593
+ const seq = runSequence ( "LKGInternal" , "VerifyLKG" ) ;
594
+ const sizeAfter = getDirSize ( lkgDirectory ) ;
595
+ if ( sizeAfter > ( sizeBefore * 1.10 ) ) {
596
+ throw new Error ( "The lib folder increased by 10% or more. This likely indicates a bug." ) ;
597
+ }
598
+ return seq ;
584
599
} ) ;
585
600
586
601
587
602
// Task to build the tests infrastructure using the built compiler
588
603
const run = path . join ( builtLocalDirectory , "run.js" ) ;
589
604
gulp . task ( run , /*help*/ false , [ servicesFile , tsserverLibraryFile ] , ( ) => {
590
- const testProject = tsc . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
605
+ const testProject = tsc_oop . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { } ) , { typescript : getCompilerPath ( /*useBuiltCompiler*/ true ) } ) ;
591
606
return testProject . src ( )
592
607
. pipe ( newer ( run ) )
593
608
. pipe ( sourcemaps . init ( ) )
@@ -1069,7 +1084,7 @@ gulp.task("build-rules", "Compiles tslint rules to js", () => {
1069
1084
gulp . task ( "lint" , "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex" , [ "build-rules" ] , ( ) => {
1070
1085
if ( fold . isTravis ( ) ) console . log ( fold . start ( "lint" ) ) ;
1071
1086
for ( const project of [ "scripts/tslint/tsconfig.json" , "src/tsconfig-base.json" ] ) {
1072
- const cmd = `node node_modules/tslint/bin/tslint --project ${ project } --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish` ;
1087
+ const cmd = `node node_modules/tslint/bin/tslint --project ${ project } --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish${ cmdLineOptions . fix ? " --fix" : "" } ` ;
1073
1088
console . log ( "Linting: " + cmd ) ;
1074
1089
child_process . execSync ( cmd , { stdio : [ 0 , 1 , 2 ] } ) ;
1075
1090
}
0 commit comments