Skip to content

Commit 9935bc0

Browse files
committed
Merge branch 'master' into update-types3
2 parents 4f61eef + e821c2b commit 9935bc0

9,241 files changed

Lines changed: 883902 additions & 25004 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ tests/baselines/local/projectOutput/*
1919
tests/baselines/reference/testresults.tap
2020
tests/services/baselines/prototyping/local/*
2121
tests/services/browser/typescriptServices.js
22-
scripts/authors.js
23-
scripts/configureNightly.js
24-
scripts/processDiagnosticMessages.d.ts
25-
scripts/processDiagnosticMessages.js
26-
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
2722
src/harness/*.js
2823
src/compiler/diagnosticInformationMap.generated.ts
2924
src/compiler/diagnosticMessages.generated.json
@@ -43,7 +38,12 @@ scripts/run.bat
4338
scripts/word2md.js
4439
scripts/buildProtocol.js
4540
scripts/ior.js
46-
scripts/buildProtocol.js
41+
scripts/authors.js
42+
scripts/configureNightly.js
43+
scripts/processDiagnosticMessages.d.ts
44+
scripts/processDiagnosticMessages.js
45+
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
46+
scripts/generateLocalizedDiagnosticMessages.js
4747
scripts/*.js.map
4848
scripts/typings/
4949
coverage/
@@ -59,3 +59,4 @@ internal/
5959
.idea
6060
yarn.lock
6161
package-lock.json
62+
.parallelperf.*

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ internal
55
issue_template.md
66
jenkins.sh
77
lib/README.md
8+
lib/enu
89
netci.groovy
910
pull_request_template.md
1011
scripts
@@ -16,5 +17,5 @@ Jakefile.js
1617
.gitattributes
1718
.settings/
1819
.travis.yml
19-
.vscode/
20+
.vscode/
2021
test.config

CopyrightNotice.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
/*! *****************************************************************************
2-
Copyright (c) Microsoft Corporation. All rights reserved.
3-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4-
this file except in compliance with the License. You may obtain a copy of the
5-
License at http://www.apache.org/licenses/LICENSE-2.0
6-
7-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10-
MERCHANTABLITY OR NON-INFRINGEMENT.
11-
12-
See the Apache Version 2.0 License for specific language governing permissions
13-
and limitations under the License.
14-
***************************************************************************** */
15-
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+

Gulpfile.ts

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ import merge2 = require("merge2");
3131
import * as os from "os";
3232
import fold = require("travis-fold");
3333
const gulp = helpMaker(originalGulp);
34-
const mochaParallel = require("./scripts/mocha-parallel.js");
35-
const {runTestsInParallel} = mochaParallel;
3634

3735
Error.stackTraceLimit = 1000;
3836

37+
/**
38+
* This regexp exists to capture our const enums and replace them with normal enums in our public API
39+
* - this is fine since we compile with preserveConstEnums, and ensures our consumers are not locked
40+
* to the TS version they compile with.
41+
*/
42+
const constEnumCaptureRegexp = /^(\s*)(export )?const enum (\S+) {(\s*)$/gm;
43+
const constEnumReplacement = "$1$2enum $3 {$4";
44+
3945
const cmdLineOptions = minimist(process.argv.slice(2), {
4046
boolean: ["debug", "inspect", "light", "colors", "lint", "soft"],
4147
string: ["browser", "tests", "host", "reporter", "stackTraceLimit", "timeout"],
@@ -89,6 +95,7 @@ const harnessDirectory = "src/harness/";
8995
const libraryDirectory = "src/lib/";
9096
const scriptsDirectory = "scripts/";
9197
const docDirectory = "doc/";
98+
const lclDirectory = "src/loc/lcl";
9299

93100
const builtDirectory = "built/";
94101
const builtLocalDirectory = "built/local/";
@@ -262,8 +269,8 @@ function getCompilerSettings(base: tsc.Settings, useBuiltCompiler?: boolean): ts
262269
}
263270
if (!useDebugMode) {
264271
if (copy.removeComments === undefined) copy.removeComments = true;
265-
copy.newLine = "lf";
266272
}
273+
copy.newLine = "lf";
267274
if (useBuiltCompiler === true) {
268275
copy.typescript = require("./built/local/typescript.js");
269276
}
@@ -369,6 +376,36 @@ gulp.task(builtGeneratedDiagnosticMessagesJSON, [diagnosticInfoMapTs], (done) =>
369376

370377
gulp.task("generate-diagnostics", "Generates a diagnostic file in TypeScript based on an input JSON file", [diagnosticInfoMapTs]);
371378

379+
// Localize diagnostics script
380+
const generateLocalizedDiagnosticMessagesJs = path.join(scriptsDirectory, "generateLocalizedDiagnosticMessages.js");
381+
const generateLocalizedDiagnosticMessagesTs = path.join(scriptsDirectory, "generateLocalizedDiagnosticMessages.ts");
382+
383+
gulp.task(generateLocalizedDiagnosticMessagesJs, /*help*/ false, [], () => {
384+
const settings: tsc.Settings = getCompilerSettings({
385+
target: "es5",
386+
declaration: false,
387+
removeComments: true,
388+
noResolve: false,
389+
stripInternal: false,
390+
types: ["node", "xml2js"]
391+
}, /*useBuiltCompiler*/ false);
392+
return gulp.src(generateLocalizedDiagnosticMessagesTs)
393+
.pipe(newer(generateLocalizedDiagnosticMessagesJs))
394+
.pipe(sourcemaps.init())
395+
.pipe(tsc(settings))
396+
.pipe(sourcemaps.write("."))
397+
.pipe(gulp.dest(scriptsDirectory));
398+
});
399+
400+
// Localize diagnostics
401+
const generatedLCGFile = path.join(builtLocalDirectory, "enu", "diagnosticMessages.generated.json.lcg");
402+
gulp.task(generatedLCGFile, [generateLocalizedDiagnosticMessagesJs, diagnosticInfoMapTs], (done) => {
403+
if (fs.existsSync(builtLocalDirectory) && needsUpdate(generatedDiagnosticMessagesJSON, generatedLCGFile)) {
404+
exec(host, [generateLocalizedDiagnosticMessagesJs, lclDirectory, builtLocalDirectory, generatedDiagnosticMessagesJSON], done, done);
405+
}
406+
});
407+
408+
gulp.task("localize", [generatedLCGFile]);
372409

373410
const servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
374411
const standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
@@ -403,7 +440,7 @@ gulp.task(servicesFile, /*help*/ false, ["lib", "generate-diagnostics"], () => {
403440
const completedDts = dts.pipe(prependCopyright(/*outputCopyright*/ true))
404441
.pipe(insert.transform((contents, file) => {
405442
file.path = standaloneDefinitionsFile;
406-
return contents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, "$1$2enum $3 {$4");
443+
return contents.replace(constEnumCaptureRegexp, constEnumReplacement);
407444
}));
408445
return merge2([
409446
completedJs,
@@ -413,7 +450,7 @@ gulp.task(servicesFile, /*help*/ false, ["lib", "generate-diagnostics"], () => {
413450
completedDts.pipe(clone())
414451
.pipe(insert.transform((content, file) => {
415452
file.path = nodeDefinitionsFile;
416-
return content + "\r\nexport = ts;";
453+
return content + "\nexport = ts;";
417454
}))
418455
.pipe(gulp.dest("src/services")),
419456
completedDts.pipe(clone())
@@ -468,7 +505,7 @@ const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js")
468505
const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
469506

470507
gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (done) => {
471-
const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
508+
const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({ removeComments: false }, /*useBuiltCompiler*/ true));
472509
const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src()
473510
.pipe(sourcemaps.init())
474511
.pipe(newer(tsserverLibraryFile))
@@ -480,7 +517,7 @@ gulp.task(tsserverLibraryFile, /*help*/ false, [servicesFile, typesMapJson], (do
480517
.pipe(gulp.dest("src/server")),
481518
dts.pipe(prependCopyright(/*outputCopyright*/ true))
482519
.pipe(insert.transform((content) => {
483-
return content + "\r\nexport = ts;\r\nexport as namespace ts;";
520+
return content.replace(constEnumCaptureRegexp, constEnumReplacement) + "\nexport = ts;\nexport as namespace ts;";
484521
}))
485522
.pipe(gulp.dest("src/server"))
486523
]);
@@ -496,7 +533,7 @@ gulp.task(typesMapJson, /*help*/ false, [], () => {
496533
});
497534

498535
gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]);
499-
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]);
536+
gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile, "localize"]);
500537
gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]);
501538

502539
// Generate Markdown spec
@@ -538,15 +575,16 @@ gulp.task("dontUseDebugMode", /*help*/ false, [], (done) => { useDebugMode = fal
538575

539576
gulp.task("VerifyLKG", /*help*/ false, [], () => {
540577
const expectedFiles = [builtLocalCompiler, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, typingsInstallerJs, cancellationTokenJs].concat(libraryTargets);
541-
const missingFiles = expectedFiles.filter(function(f) {
542-
return !fs.existsSync(f);
543-
});
578+
const missingFiles = expectedFiles.
579+
concat(fs.readdirSync(lclDirectory).map(function (d) { return path.join(builtLocalDirectory, d, "diagnosticMessages.generated.json"); })).
580+
concat(generatedLCGFile).
581+
filter(f => !fs.existsSync(f));
544582
if (missingFiles.length > 0) {
545583
throw new Error("Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory +
546584
". The following files are missing:\n" + missingFiles.join("\n"));
547585
}
548586
// Copy all the targets into the LKG directory
549-
return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory));
587+
return gulp.src([...expectedFiles, path.join(builtLocalDirectory, "**"), `!${path.join(builtLocalDirectory, "tslint")}`, `!${path.join(builtLocalDirectory, "*.*")}`]).pipe(gulp.dest(LKGDirectory));
550588
});
551589

552590
gulp.task("LKGInternal", /*help*/ false, ["lib", "local"]);
@@ -558,7 +596,7 @@ gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUse
558596

559597
// Task to build the tests infrastructure using the built compiler
560598
const run = path.join(builtLocalDirectory, "run.js");
561-
gulp.task(run, /*help*/ false, [servicesFile], () => {
599+
gulp.task(run, /*help*/ false, [servicesFile, tsserverLibraryFile], () => {
562600
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
563601
return testProject.src()
564602
.pipe(newer(run))
@@ -668,36 +706,18 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
668706
}
669707
else {
670708
// run task to load all tests and partition them between workers
671-
const args = [];
672-
args.push("-R", "min");
673-
if (colors) {
674-
args.push("--colors");
675-
}
676-
else {
677-
args.push("--no-colors");
678-
}
679-
args.push(run);
680709
setNodeEnvToDevelopment();
681-
runTestsInParallel(taskConfigsFolder, run, { testTimeout, noColors: colors === " --no-colors " }, function(err) {
682-
// last worker clean everything and runs linter in case if there were no errors
683-
del(taskConfigsFolder).then(() => {
684-
if (!err) {
685-
lintThenFinish();
686-
}
687-
else {
688-
finish(err);
689-
}
690-
});
710+
exec(host, [run], lintThenFinish, function(e, status) {
711+
finish(e, status);
691712
});
692713
}
693714
});
694715

695716
function failWithStatus(err?: any, status?: number) {
696-
if (err) {
697-
console.log(err);
717+
if (err || status) {
718+
process.exit(typeof status === "number" ? status : 2);
698719
}
699-
done(err || status);
700-
process.exit(status);
720+
done();
701721
}
702722

703723
function lintThenFinish() {
@@ -711,7 +731,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
711731

712732
function finish(error?: any, errorStatus?: number) {
713733
restoreSavedNodeEnv();
714-
deleteTemporaryProjectOutput().then(() => {
734+
deleteTestConfig().then(deleteTemporaryProjectOutput).then(() => {
715735
if (error !== undefined || errorStatus !== undefined) {
716736
failWithStatus(error, errorStatus);
717737
}
@@ -720,6 +740,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
720740
}
721741
});
722742
}
743+
744+
function deleteTestConfig() {
745+
return del("test.config");
746+
}
723747
}
724748

725749
gulp.task("runtests-parallel", "Runs all the tests in parallel using the built run.js file. Optional arguments are: --t[ests]=category1|category2|... --d[ebug]=true.", ["build-rules", "tests"], (done) => {
@@ -836,7 +860,7 @@ function cleanTestDirs(done: (e?: any) => void) {
836860

837861
// used to pass data from jake command line directly to run.js
838862
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
839-
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder });
863+
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions["colors"] });
840864
console.log("Running tests with config: " + testConfigContents);
841865
fs.writeFileSync("test.config", testConfigContents);
842866
}
@@ -994,8 +1018,9 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => {
9941018
.pipe(gulp.dest(builtLocalDirectory));
9951019
});
9961020

997-
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
998-
exec(host, [instrumenterJsPath, "record", "iocapture", builtLocalCompiler], done, done);
1021+
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js - run with --test=[testname]", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
1022+
const test = cmdLineOptions["tests"] || "iocapture";
1023+
exec(host, [instrumenterJsPath, "record", test, builtLocalCompiler], done, done);
9991024
});
10001025

10011026
gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", serverFile], () => {
@@ -1066,10 +1091,11 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are:
10661091
const fileMatcher = cmdLineOptions["files"];
10671092
const files = fileMatcher
10681093
? `src/**/${fileMatcher}`
1069-
: "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1070-
const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`;
1094+
: "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'";
1095+
const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`;
10711096
console.log("Linting: " + cmd);
10721097
child_process.execSync(cmd, { stdio: [0, 1, 2] });
1098+
if (fold.isTravis()) console.log(fold.end("lint"));
10731099
});
10741100

10751101
gulp.task("default", "Runs 'local'", ["local"]);

0 commit comments

Comments
 (0)