@@ -85,12 +85,9 @@ let host = cmdLineOptions["host"];
8585
8686// Constants
8787const compilerDirectory = "src/compiler/" ;
88- const servicesDirectory = "src/services/" ;
89- const serverDirectory = "src/server/" ;
9088const harnessDirectory = "src/harness/" ;
9189const libraryDirectory = "src/lib/" ;
9290const scriptsDirectory = "scripts/" ;
93- const unittestsDirectory = "tests/cases/unittests/" ;
9491const docDirectory = "doc/" ;
9592
9693const builtDirectory = "built/" ;
@@ -107,69 +104,6 @@ const nodeModulesPathPrefix = path.resolve("./node_modules/.bin/");
107104const isWin = / ^ w i n / . test ( process . platform ) ;
108105const mocha = path . join ( nodeModulesPathPrefix , "mocha" ) + ( isWin ? ".cmd" : "" ) ;
109106
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-
173107const es2015LibrarySources = [
174108 "es2015.core.d.ts" ,
175109 "es2015.collection.d.ts" ,
@@ -500,21 +434,18 @@ const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js")
500434const tsserverLibraryDefinitionFile = path . join ( builtLocalDirectory , "tsserverlibrary.d.ts" ) ;
501435
502436gulp . 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 ( )
508439 . pipe ( sourcemaps . init ( ) )
509440 . pipe ( newer ( tsserverLibraryFile ) )
510- . pipe ( tsc ( settings ) ) ;
441+ . pipe ( tsc ( serverLibraryProject ) ) ;
511442
512443 return merge2 ( [
513444 js . pipe ( prependCopyright ( ) )
514445 . pipe ( sourcemaps . write ( "." ) )
515- . pipe ( gulp . dest ( "." ) ) ,
446+ . pipe ( gulp . dest ( builtLocalDirectory ) ) ,
516447 dts . pipe ( prependCopyright ( ) )
517- . pipe ( gulp . dest ( "." ) )
448+ . pipe ( gulp . dest ( builtLocalDirectory ) )
518449 ] ) ;
519450} ) ;
520451
@@ -583,15 +514,13 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
583514// Task to build the tests infrastructure using the built compiler
584515const run = path . join ( builtLocalDirectory , "run.js" ) ;
585516gulp . 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 ( )
590519 . pipe ( newer ( run ) )
591520 . pipe ( sourcemaps . init ( ) )
592- . pipe ( tsc ( settings ) )
521+ . pipe ( tsc ( testProject ) )
593522 . pipe ( sourcemaps . write ( "." , { includeContent : false , sourceRoot : "../../" } ) )
594- . pipe ( gulp . dest ( "." ) ) ;
523+ . pipe ( gulp . dest ( builtLocalDirectory ) ) ;
595524} ) ;
596525
597526const internalTests = "internal/" ;
@@ -766,13 +695,11 @@ gulp.task(nodeServerOutFile, false, [servicesFile], () => {
766695} ) ;
767696
768697gulp . 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 ( )
773700 . pipe ( newer ( "built/local/bundle.js" ) )
774701 . pipe ( sourcemaps . init ( ) )
775- . pipe ( tsc ( settings ) )
702+ . pipe ( tsc ( testProject ) )
776703 . pipe ( through2 . obj ( ( file , enc , next ) => {
777704 browserify ( intoStream ( file . contents ) )
778705 . bundle ( ( err , res ) => {
@@ -1013,36 +940,38 @@ function lintFile(options, path) {
1013940 return lintFileContents ( options , path , contents ) ;
1014941}
1015942
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+ "tests/cases/unittests/**/*.ts" ,
948+ "!tests/cases/unittests/services/formatting/**/*.ts" ,
949+ "src/server/**/*.ts" ,
950+ "scripts/tslint/**/*.ts" ,
951+ "src/services/**/*.ts" ,
952+ ] ;
1024953
1025954
1026955gulp . task ( "lint" , "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex" , [ "build-rules" ] , ( ) => {
956+ const fileMatcher = RegExp ( cmdLineOptions [ "files" ] ) ;
1027957 const lintOptions = getLinterOptions ( ) ;
1028958 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 ) ;
959+ return gulp . src ( lintTargets )
960+ . pipe ( insert . transform ( ( contents , file ) => {
961+ if ( ! fileMatcher . test ( file . path ) ) return contents ;
962+ const result = lintFile ( lintOptions , file . path ) ;
1035963 if ( result . failureCount > 0 ) {
1036964 console . log ( result . output ) ;
1037965 failed += result . failureCount ;
1038966 }
1039- done [ target ] = true ;
1040- }
1041- }
1042- if ( failed > 0 ) {
1043- console . error ( "Linter errors." ) ;
1044- process . exit ( 1 ) ;
1045- }
967+ return contents ; // TODO (weswig): Automatically apply fixes? :3
968+ } ) )
969+ . on ( "end" , ( ) => {
970+ if ( failed > 0 ) {
971+ console . error ( "Linter errors." ) ;
972+ process . exit ( 1 ) ;
973+ }
974+ } ) ;
1046975} ) ;
1047976
1048977
0 commit comments