@@ -85,12 +85,9 @@ let host = cmdLineOptions["host"];
85
85
86
86
// Constants
87
87
const compilerDirectory = "src/compiler/" ;
88
- const servicesDirectory = "src/services/" ;
89
- const serverDirectory = "src/server/" ;
90
88
const harnessDirectory = "src/harness/" ;
91
89
const libraryDirectory = "src/lib/" ;
92
90
const scriptsDirectory = "scripts/" ;
93
- const unittestsDirectory = "tests/cases/unittests/" ;
94
91
const docDirectory = "doc/" ;
95
92
96
93
const builtDirectory = "built/" ;
@@ -107,69 +104,6 @@ const nodeModulesPathPrefix = path.resolve("./node_modules/.bin/");
107
104
const isWin = / ^ w i n / . test ( process . platform ) ;
108
105
const mocha = path . join ( nodeModulesPathPrefix , "mocha" ) + ( isWin ? ".cmd" : "" ) ;
109
106
110
- const compilerSources = require ( "./src/compiler/tsconfig.json" ) . files . map ( ( file ) => path . join ( compilerDirectory , file ) ) ;
111
-
112
- const servicesSources = require ( "./src/services/tsconfig.json" ) . files . map ( ( file ) => path . join ( servicesDirectory , file ) ) ;
113
-
114
- const serverCoreSources = require ( "./src/server/tsconfig.json" ) . files . map ( ( file ) => path . join ( serverDirectory , file ) ) ;
115
-
116
- const languageServiceLibrarySources = [
117
- "editorServices.ts" ,
118
- "protocol.d.ts" ,
119
- "session.ts"
120
- ] . map ( function ( f ) {
121
- return path . join ( serverDirectory , f ) ;
122
- } ) . concat ( servicesSources ) ;
123
-
124
- const harnessCoreSources = [
125
- "harness.ts" ,
126
- "sourceMapRecorder.ts" ,
127
- "harnessLanguageService.ts" ,
128
- "fourslash.ts" ,
129
- "runnerbase.ts" ,
130
- "compilerRunner.ts" ,
131
- "typeWriter.ts" ,
132
- "fourslashRunner.ts" ,
133
- "projectsRunner.ts" ,
134
- "loggedIO.ts" ,
135
- "rwcRunner.ts" ,
136
- "test262Runner.ts" ,
137
- "runner.ts"
138
- ] . map ( function ( f ) {
139
- return path . join ( harnessDirectory , f ) ;
140
- } ) ;
141
-
142
- const harnessSources = harnessCoreSources . concat ( [
143
- "incrementalParser.ts" ,
144
- "jsDocParsing.ts" ,
145
- "services/colorization.ts" ,
146
- "services/documentRegistry.ts" ,
147
- "services/preProcessFile.ts" ,
148
- "services/patternMatcher.ts" ,
149
- "session.ts" ,
150
- "versionCache.ts" ,
151
- "convertToBase64.ts" ,
152
- "transpile.ts" ,
153
- "reuseProgramStructure.ts" ,
154
- "cachingInServerLSHost.ts" ,
155
- "moduleResolution.ts" ,
156
- "tsconfigParsing.ts" ,
157
- "commandLineParsing.ts" ,
158
- "convertCompilerOptionsFromJson.ts" ,
159
- "convertTypingOptionsFromJson.ts" ,
160
- "tsserverProjectSystem.ts" ,
161
- "matchFiles.ts" ,
162
- ] . map ( function ( f ) {
163
- return path . join ( unittestsDirectory , f ) ;
164
- } ) ) . concat ( [
165
- "protocol.d.ts" ,
166
- "session.ts" ,
167
- "client.ts" ,
168
- "editorServices.ts"
169
- ] . map ( function ( f ) {
170
- return path . join ( serverDirectory , f ) ;
171
- } ) ) ;
172
-
173
107
const es2015LibrarySources = [
174
108
"es2015.core.d.ts" ,
175
109
"es2015.collection.d.ts" ,
@@ -500,21 +434,18 @@ const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js")
500
434
const tsserverLibraryDefinitionFile = path . join ( builtLocalDirectory , "tsserverlibrary.d.ts" ) ;
501
435
502
436
gulp . task ( tsserverLibraryFile , false , [ servicesFile ] , ( done ) => {
503
- const settings : tsc . Settings = getCompilerSettings ( {
504
- declaration : true ,
505
- outFile : tsserverLibraryFile
506
- } , /*useBuiltCompiler*/ true ) ;
507
- const { js, dts} : { js : NodeJS . ReadableStream , dts : NodeJS . ReadableStream } = gulp . src ( languageServiceLibrarySources )
437
+ const serverLibraryProject = tsc . createProject ( "src/server/tsconfig.library.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
438
+ const { js, dts} : { js : NodeJS . ReadableStream , dts : NodeJS . ReadableStream } = serverLibraryProject . src ( )
508
439
. pipe ( sourcemaps . init ( ) )
509
440
. pipe ( newer ( tsserverLibraryFile ) )
510
- . pipe ( tsc ( settings ) ) ;
441
+ . pipe ( tsc ( serverLibraryProject ) ) ;
511
442
512
443
return merge2 ( [
513
444
js . pipe ( prependCopyright ( ) )
514
445
. pipe ( sourcemaps . write ( "." ) )
515
- . pipe ( gulp . dest ( "." ) ) ,
446
+ . pipe ( gulp . dest ( builtLocalDirectory ) ) ,
516
447
dts . pipe ( prependCopyright ( ) )
517
- . pipe ( gulp . dest ( "." ) )
448
+ . pipe ( gulp . dest ( builtLocalDirectory ) )
518
449
] ) ;
519
450
} ) ;
520
451
@@ -583,15 +514,13 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
583
514
// Task to build the tests infrastructure using the built compiler
584
515
const run = path . join ( builtLocalDirectory , "run.js" ) ;
585
516
gulp . task ( run , false , [ servicesFile ] , ( ) => {
586
- const settings : tsc . Settings = getCompilerSettings ( {
587
- outFile : run
588
- } , /*useBuiltCompiler*/ true ) ;
589
- return gulp . src ( harnessSources )
517
+ const testProject = tsc . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { } , /*useBuiltCompiler*/ true ) ) ;
518
+ return testProject . src ( )
590
519
. pipe ( newer ( run ) )
591
520
. pipe ( sourcemaps . init ( ) )
592
- . pipe ( tsc ( settings ) )
521
+ . pipe ( tsc ( testProject ) )
593
522
. pipe ( sourcemaps . write ( "." , { includeContent : false , sourceRoot : "../../" } ) )
594
- . pipe ( gulp . dest ( "." ) ) ;
523
+ . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
595
524
} ) ;
596
525
597
526
const internalTests = "internal/" ;
@@ -766,13 +695,11 @@ gulp.task(nodeServerOutFile, false, [servicesFile], () => {
766
695
} ) ;
767
696
768
697
gulp . task ( "browserify" , "Runs browserify on run.js to produce a file suitable for running tests in the browser" , [ servicesFile ] , ( done ) => {
769
- const settings : tsc . Settings = getCompilerSettings ( {
770
- outFile : "built/local/bundle.js"
771
- } , /*useBuiltCompiler*/ true ) ;
772
- return gulp . src ( harnessSources )
698
+ const testProject = tsc . createProject ( "src/harness/tsconfig.json" , getCompilerSettings ( { outFile : "built/local/bundle.js" } , /*useBuiltCompiler*/ true ) ) ;
699
+ return testProject . src ( )
773
700
. pipe ( newer ( "built/local/bundle.js" ) )
774
701
. pipe ( sourcemaps . init ( ) )
775
- . pipe ( tsc ( settings ) )
702
+ . pipe ( tsc ( testProject ) )
776
703
. pipe ( through2 . obj ( ( file , enc , next ) => {
777
704
browserify ( intoStream ( file . contents ) )
778
705
. bundle ( ( err , res ) => {
@@ -1013,36 +940,37 @@ function lintFile(options, path) {
1013
940
return lintFileContents ( options , path , contents ) ;
1014
941
}
1015
942
1016
- const lintTargets = [ "Gulpfile.ts" ]
1017
- . concat ( compilerSources )
1018
- . concat ( harnessSources )
1019
- // Other harness sources
1020
- . concat ( [ "instrumenter.ts" ] . map ( function ( f ) { return path . join ( harnessDirectory , f ) ; } ) )
1021
- . concat ( serverCoreSources )
1022
- . concat ( tslintRulesFiles )
1023
- . concat ( servicesSources ) ;
943
+ const lintTargets = [
944
+ "Gulpfile.ts" ,
945
+ "src/compiler/**/*.ts" ,
946
+ "src/harness/**/*.ts" ,
947
+ "!src/harness/unittests/services/formatting/**/*.ts" ,
948
+ "src/server/**/*.ts" ,
949
+ "scripts/tslint/**/*.ts" ,
950
+ "src/services/**/*.ts" ,
951
+ ] ;
1024
952
1025
953
1026
954
gulp . task ( "lint" , "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex" , [ "build-rules" ] , ( ) => {
955
+ const fileMatcher = RegExp ( cmdLineOptions [ "files" ] ) ;
1027
956
const lintOptions = getLinterOptions ( ) ;
1028
957
let failed = 0 ;
1029
- const fileMatcher = RegExp ( cmdLineOptions [ "files" ] ) ;
1030
- const done = { } ;
1031
- for ( const i in lintTargets ) {
1032
- const target = lintTargets [ i ] ;
1033
- if ( ! done [ target ] && fileMatcher . test ( target ) ) {
1034
- const result = lintFile ( lintOptions , target ) ;
958
+ return gulp . src ( lintTargets )
959
+ . pipe ( insert . transform ( ( contents , file ) => {
960
+ if ( ! fileMatcher . test ( file . path ) ) return contents ;
961
+ const result = lintFile ( lintOptions , file . path ) ;
1035
962
if ( result . failureCount > 0 ) {
1036
963
console . log ( result . output ) ;
1037
964
failed += result . failureCount ;
1038
965
}
1039
- done [ target ] = true ;
1040
- }
1041
- }
1042
- if ( failed > 0 ) {
1043
- console . error ( "Linter errors." ) ;
1044
- process . exit ( 1 ) ;
1045
- }
966
+ return contents ; // TODO (weswig): Automatically apply fixes? :3
967
+ } ) )
968
+ . on ( "end" , ( ) => {
969
+ if ( failed > 0 ) {
970
+ console . error ( "Linter errors." ) ;
971
+ process . exit ( 1 ) ;
972
+ }
973
+ } ) ;
1046
974
} ) ;
1047
975
1048
976
0 commit comments