Skip to content

Commit 0a1d75d

Browse files
authored
use tsconfig.json files in jake (microsoft#13869)
1 parent 915ffab commit 0a1d75d

File tree

1 file changed

+32
-169
lines changed

1 file changed

+32
-169
lines changed

Jakefile.js

Lines changed: 32 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var path = require("path");
66
var child_process = require("child_process");
77
var fold = require("travis-fold");
88
var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel;
9+
var ts = require("./lib/typescript");
10+
911

1012
// Variables
1113
var compilerDirectory = "src/compiler/";
@@ -34,6 +36,25 @@ if (process.env.path !== undefined) {
3436
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
3537
}
3638

39+
function filesFromConfig(configPath) {
40+
console.log(configPath);
41+
var configText = fs.readFileSync(configPath).toString();
42+
var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true);
43+
if (config.error) {
44+
throw new Error(diagnosticsToString([config.error]));
45+
}
46+
const configFileContent = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
47+
if (configFileContent.errors && configFileContent.errors.length) {
48+
throw new Error(diagnosticsToString(configFileContent.errors));
49+
}
50+
51+
return configFileContent.fileNames;
52+
53+
function diagnosticsToString(s) {
54+
return s.map(function(e) { return ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine); }).join(ts.sys.newLine);
55+
}
56+
}
57+
3758
function toNs(diff) {
3859
return diff[0] * 1e9 + diff[1];
3960
}
@@ -56,173 +77,12 @@ function measure(marker) {
5677
console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r");
5778
}
5879

59-
var compilerSources = [
60-
"core.ts",
61-
"performance.ts",
62-
"sys.ts",
63-
"types.ts",
64-
"scanner.ts",
65-
"parser.ts",
66-
"utilities.ts",
67-
"binder.ts",
68-
"checker.ts",
69-
"factory.ts",
70-
"visitor.ts",
71-
"transformers/destructuring.ts",
72-
"transformers/ts.ts",
73-
"transformers/jsx.ts",
74-
"transformers/esnext.ts",
75-
"transformers/es2017.ts",
76-
"transformers/es2016.ts",
77-
"transformers/es2015.ts",
78-
"transformers/generators.ts",
79-
"transformers/es5.ts",
80-
"transformers/module/es2015.ts",
81-
"transformers/module/system.ts",
82-
"transformers/module/module.ts",
83-
"transformer.ts",
84-
"sourcemap.ts",
85-
"comments.ts",
86-
"declarationEmitter.ts",
87-
"emitter.ts",
88-
"program.ts",
89-
"commandLineParser.ts",
90-
"tsc.ts",
91-
"diagnosticInformationMap.generated.ts"
92-
].map(function (f) {
93-
return path.join(compilerDirectory, f);
94-
});
95-
96-
var servicesSources = [
97-
"core.ts",
98-
"performance.ts",
99-
"sys.ts",
100-
"types.ts",
101-
"scanner.ts",
102-
"parser.ts",
103-
"utilities.ts",
104-
"binder.ts",
105-
"checker.ts",
106-
"factory.ts",
107-
"visitor.ts",
108-
"transformers/destructuring.ts",
109-
"transformers/ts.ts",
110-
"transformers/jsx.ts",
111-
"transformers/esnext.ts",
112-
"transformers/es2017.ts",
113-
"transformers/es2016.ts",
114-
"transformers/es2015.ts",
115-
"transformers/generators.ts",
116-
"transformers/es5.ts",
117-
"transformers/module/es2015.ts",
118-
"transformers/module/system.ts",
119-
"transformers/module/module.ts",
120-
"transformer.ts",
121-
"sourcemap.ts",
122-
"comments.ts",
123-
"declarationEmitter.ts",
124-
"emitter.ts",
125-
"program.ts",
126-
"commandLineParser.ts",
127-
"diagnosticInformationMap.generated.ts"
128-
].map(function (f) {
129-
return path.join(compilerDirectory, f);
130-
}).concat([
131-
"types.ts",
132-
"utilities.ts",
133-
"breakpoints.ts",
134-
"classifier.ts",
135-
"completions.ts",
136-
"documentHighlights.ts",
137-
"documentRegistry.ts",
138-
"findAllReferences.ts",
139-
"goToDefinition.ts",
140-
"goToImplementation.ts",
141-
"jsDoc.ts",
142-
"jsTyping.ts",
143-
"navigateTo.ts",
144-
"navigationBar.ts",
145-
"outliningElementsCollector.ts",
146-
"patternMatcher.ts",
147-
"preProcess.ts",
148-
"rename.ts",
149-
"services.ts",
150-
"shims.ts",
151-
"signatureHelp.ts",
152-
"symbolDisplay.ts",
153-
"transpile.ts",
154-
// Formatting
155-
"formatting/formatting.ts",
156-
"formatting/formattingContext.ts",
157-
"formatting/formattingRequestKind.ts",
158-
"formatting/formattingScanner.ts",
159-
"formatting/references.ts",
160-
"formatting/rule.ts",
161-
"formatting/ruleAction.ts",
162-
"formatting/ruleDescriptor.ts",
163-
"formatting/ruleFlag.ts",
164-
"formatting/ruleOperation.ts",
165-
"formatting/ruleOperationContext.ts",
166-
"formatting/rules.ts",
167-
"formatting/rulesMap.ts",
168-
"formatting/rulesProvider.ts",
169-
"formatting/smartIndenter.ts",
170-
"formatting/tokenRange.ts",
171-
// CodeFixes
172-
"codeFixProvider.ts",
173-
"codefixes/fixes.ts",
174-
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
175-
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
176-
"codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
177-
"codefixes/fixClassSuperMustPrecedeThisAccess.ts",
178-
"codefixes/fixConstructorForDerivedNeedSuperCall.ts",
179-
"codefixes/helpers.ts",
180-
"codefixes/importFixes.ts",
181-
"codefixes/unusedIdentifierFixes.ts"
182-
].map(function (f) {
183-
return path.join(servicesDirectory, f);
184-
}));
185-
186-
var baseServerCoreSources = [
187-
"builder.ts",
188-
"editorServices.ts",
189-
"lsHost.ts",
190-
"project.ts",
191-
"protocol.ts",
192-
"scriptInfo.ts",
193-
"scriptVersionCache.ts",
194-
"session.ts",
195-
"shared.ts",
196-
"types.ts",
197-
"typingsCache.ts",
198-
"utilities.ts",
199-
].map(function (f) {
200-
return path.join(serverDirectory, f);
201-
});
202-
203-
var serverCoreSources = [
204-
"server.ts"
205-
].map(function (f) {
206-
return path.join(serverDirectory, f);
207-
}).concat(baseServerCoreSources);
208-
209-
var cancellationTokenSources = [
210-
"cancellationToken.ts"
211-
].map(function (f) {
212-
return path.join(cancellationTokenDirectory, f);
213-
});
214-
215-
var typingsInstallerSources = [
216-
"../types.ts",
217-
"../shared.ts",
218-
"typingsInstaller.ts",
219-
"nodeTypingsInstaller.ts"
220-
].map(function (f) {
221-
return path.join(typingsInstallerDirectory, f);
222-
});
223-
224-
var serverSources = serverCoreSources.concat(servicesSources);
225-
var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources);
80+
var compilerSources = filesFromConfig("./src/compiler/tsconfig.json");
81+
var servicesSources = filesFromConfig("./src/services/tsconfig.json");
82+
var cancellationTokenSources = filesFromConfig(path.join(serverDirectory, "cancellationToken/tsconfig.json"));
83+
var typingsInstallerSources = filesFromConfig(path.join(serverDirectory, "typingsInstaller/tsconfig.json"));
84+
var serverSources = filesFromConfig(path.join(serverDirectory, "tsconfig.json"))
85+
var languageServiceLibrarySources = filesFromConfig(path.join(serverDirectory, "tsconfig.library.json"));
22686

22787
var harnessCoreSources = [
22888
"harness.ts",
@@ -1230,13 +1090,16 @@ var lintTargets = compilerSources
12301090
.concat(harnessSources)
12311091
// Other harness sources
12321092
.concat(["instrumenter.ts"].map(function (f) { return path.join(harnessDirectory, f) }))
1233-
.concat(serverCoreSources)
1093+
.concat(serverSources)
12341094
.concat(tslintRulesFiles)
12351095
.concat(servicesSources)
12361096
.concat(typingsInstallerSources)
12371097
.concat(cancellationTokenSources)
12381098
.concat(["Gulpfile.ts"])
1239-
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
1099+
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath])
1100+
.map(function (p) { return path.resolve(p) });
1101+
// keep only unique items
1102+
lintTargets = Array.from(new Set(lintTargets));
12401103

12411104
function sendNextFile(files, child, callback, failures) {
12421105
var file = files.pop();

0 commit comments

Comments
 (0)