typescript-src 1.4.1.3 → 1.6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -0
- data/lib/typescript-src.rb +6 -1
- data/lib/typescript-src/support/typescript/.editorconfig +10 -0
- data/lib/typescript-src/support/typescript/.gitattributes +2 -0
- data/lib/typescript-src/support/typescript/.npmignore +8 -7
- data/lib/typescript-src/support/typescript/AUTHORS.md +70 -0
- data/lib/typescript-src/support/typescript/CONTRIBUTING.md +49 -18
- data/lib/typescript-src/support/typescript/Jakefile.js +795 -0
- data/lib/typescript-src/support/typescript/README.md +20 -4
- data/lib/typescript-src/support/typescript/bin/tsc +2 -2
- data/lib/typescript-src/support/typescript/bin/tsserver +2 -0
- data/lib/typescript-src/support/typescript/lib/lib.core.d.ts +3840 -0
- data/lib/typescript-src/support/typescript/{bin → lib}/lib.core.es6.d.ts +1747 -1420
- data/lib/typescript-src/support/typescript/{bin/lib.es6.d.ts → lib/lib.d.ts} +12054 -11947
- data/lib/typescript-src/support/typescript/{bin → lib}/lib.dom.d.ts +11167 -11015
- data/lib/typescript-src/support/typescript/{bin/lib.d.ts → lib/lib.es6.d.ts} +15023 -10641
- data/lib/typescript-src/support/typescript/lib/lib.scriptHost.d.ts +294 -0
- data/lib/typescript-src/support/typescript/lib/lib.webworker.d.ts +1202 -0
- data/lib/typescript-src/support/typescript/lib/tsc.js +31079 -0
- data/lib/typescript-src/support/typescript/lib/tsserver.js +44390 -0
- data/lib/typescript-src/support/typescript/lib/typescript.d.ts +2145 -0
- data/lib/typescript-src/support/typescript/lib/typescript.js +49349 -0
- data/lib/typescript-src/support/typescript/lib/typescriptServices.d.ts +2143 -0
- data/lib/typescript-src/support/typescript/lib/typescriptServices.js +49349 -0
- data/lib/typescript-src/support/typescript/package.json +77 -69
- data/lib/typescript-src/support/typescript/tslint.json +34 -0
- data/lib/typescript-src/version.rb +1 -1
- metadata +21 -15
- data/lib/typescript-src/support/typescript/bin/lib.core.d.ts +0 -1164
- data/lib/typescript-src/support/typescript/bin/lib.scriptHost.d.ts +0 -38
- data/lib/typescript-src/support/typescript/bin/lib.webworker.d.ts +0 -1652
- data/lib/typescript-src/support/typescript/bin/tsc.js +0 -18289
- data/lib/typescript-src/support/typescript/bin/typescript.d.ts +0 -1849
- data/lib/typescript-src/support/typescript/bin/typescriptServices.d.ts +0 -1849
- data/lib/typescript-src/support/typescript/bin/typescriptServices.js +0 -26273
- data/lib/typescript-src/support/typescript/bin/typescriptServices_internal.d.ts +0 -258
- data/lib/typescript-src/support/typescript/bin/typescript_internal.d.ts +0 -258
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d65a6565fb8fb8622095b8e53fe5c23ad9d714ee
|
4
|
+
data.tar.gz: 31ee8642cbce0947b10d8dc31428eeff9c5d13c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0be92e9650b168fc640024f09f220f631b9ef1e1b986124d8d9242810f56bd8cc3ee8e321f5d5a8c6f603060b92f76f83b679162a933386af2ed111c97c29d86
|
7
|
+
data.tar.gz: c8f727ac6518057d56f39b40ce9df504c29ec550f0075aa5d03b79e3eca1618fef449cf73f51d68799f0aeaabd9061c6a15cf4569c22df588b4e0946d2dd5a66
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v1.5.3.1 2015-09-30 11:34:00+0300
|
2
|
+
* Updated Typescript to v1.6.2
|
3
|
+
|
4
|
+
## v1.5.3.1 2015-09-02 11:28:00+0300
|
5
|
+
* Updated Typescript to v1.5.3
|
6
|
+
* Added support of different tsc.js path for 1.6 prerelease Typescript
|
7
|
+
|
1
8
|
## v1.4.1.3 2015-06-29 21:37:00+0300
|
2
9
|
* Updated Typescript to v1.4.1
|
3
10
|
* Added option `use_external_tsc` (boolean). It could be helpful if you have locally installed Typescript node.js module and want to use it.
|
data/lib/typescript-src.rb
CHANGED
@@ -27,7 +27,12 @@ module TypeScript
|
|
27
27
|
|
28
28
|
# @return [Pathname]
|
29
29
|
def js_path
|
30
|
-
typescript_path.join('
|
30
|
+
bin_tsc = typescript_path.join('lib/tsc.js')
|
31
|
+
if ::File.exist?(bin_tsc)
|
32
|
+
bin_tsc
|
33
|
+
else
|
34
|
+
typescript_path.join('bin/tsc.js')
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
# @return [Pathname]
|
@@ -1,7 +1,8 @@
|
|
1
|
-
built
|
2
|
-
doc
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
built
|
2
|
+
doc
|
3
|
+
scripts
|
4
|
+
src
|
5
|
+
tests
|
6
|
+
Jakefile
|
7
|
+
.travis.yml
|
8
|
+
.settings/
|
@@ -0,0 +1,70 @@
|
|
1
|
+
TypeScript is authored by:
|
2
|
+
|
3
|
+
* Adam Freidin
|
4
|
+
* Ahmad Farid
|
5
|
+
* Anders Hejlsberg
|
6
|
+
* Arnav Singh
|
7
|
+
* Arthur Ozga
|
8
|
+
* Basarat Ali Syed
|
9
|
+
* Ben Duffield
|
10
|
+
* Bill Ticehurst
|
11
|
+
* Bryan Forbes
|
12
|
+
* Caitlin Potter
|
13
|
+
* Chris Bubernak
|
14
|
+
* Colby Russell
|
15
|
+
* Colin Snover
|
16
|
+
* Cyrus Najmabadi
|
17
|
+
* Dan Quirk
|
18
|
+
* Daniel Rosenwasser
|
19
|
+
* David Li
|
20
|
+
* Dick van den Brink
|
21
|
+
* Dirk B�umer
|
22
|
+
* Frank Wallis
|
23
|
+
* Gabriel Isenberg
|
24
|
+
* Gilad Peleg
|
25
|
+
* Guillaume Salles
|
26
|
+
* Harald Niesche
|
27
|
+
* Ingvar Stepanyan
|
28
|
+
* Ivo Gabe de Wolff
|
29
|
+
* James Whitney
|
30
|
+
* Jason Freeman
|
31
|
+
* Jason Ramsay
|
32
|
+
* Jed Mao
|
33
|
+
* Johannes Rieken
|
34
|
+
* Jonathan Bond-Caron
|
35
|
+
* Jonathan Park
|
36
|
+
* Jonathan Turner
|
37
|
+
* Josh Kalderimis
|
38
|
+
* Kagami Sascha Rosylight
|
39
|
+
* Keith Mashinter
|
40
|
+
* Kenji Imamula
|
41
|
+
* Lorant Pinter
|
42
|
+
* Masahiro Wakame
|
43
|
+
* Max Deepfield
|
44
|
+
* Micah Zoltu
|
45
|
+
* Mohamed Hegazy
|
46
|
+
* Oleg Mihailik
|
47
|
+
* Oleksandr Chekhovskyi
|
48
|
+
* Paul van Brenk
|
49
|
+
* Pedro Maltez
|
50
|
+
* Philip Bulley
|
51
|
+
* piloopin
|
52
|
+
* Ron Buckton
|
53
|
+
* Ryan Cavanaugh
|
54
|
+
* Sheetal Nandi
|
55
|
+
* Shengping Zhong
|
56
|
+
* Shyyko Serhiy
|
57
|
+
* Simon H�rlimann
|
58
|
+
* Solal Pirelli
|
59
|
+
* Stan Thomas
|
60
|
+
* Steve Lucco
|
61
|
+
* Tien Hoanhtien
|
62
|
+
* Tingan Ho
|
63
|
+
* togru
|
64
|
+
* Tomas Grubliauskas
|
65
|
+
* TruongSinh Tran-Nguyen
|
66
|
+
* Vladimir Matveev
|
67
|
+
* Wesley Wigham
|
68
|
+
* Yui Tanglertsampan
|
69
|
+
* Zev Spitz
|
70
|
+
* Zhengbo Li
|
@@ -9,7 +9,7 @@ Design changes will not be accepted at this time. If you have a design change pr
|
|
9
9
|
## Legal
|
10
10
|
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
|
11
11
|
|
12
|
-
Please submit a Contributor License Agreement (CLA) before submitting a pull request.
|
12
|
+
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features.
|
13
13
|
|
14
14
|
## Housekeeping
|
15
15
|
Your pull request should:
|
@@ -25,50 +25,81 @@ Your pull request should:
|
|
25
25
|
* Tests should include reasonable permutations of the target fix/change
|
26
26
|
* Include baseline changes with your change
|
27
27
|
* All changed code must have 100% code coverage
|
28
|
-
* Follow the code conventions descriped in [Coding
|
28
|
+
* Follow the code conventions descriped in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
|
29
29
|
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
|
30
30
|
|
31
31
|
## Running the Tests
|
32
32
|
To run all tests, invoke the runtests target using jake:
|
33
33
|
|
34
|
-
|
34
|
+
```Shell
|
35
|
+
jake runtests
|
36
|
+
```
|
35
37
|
|
36
38
|
This run will all tests; to run only a specific subset of tests, use:
|
37
39
|
|
38
|
-
|
40
|
+
```Shell
|
41
|
+
jake runtests tests=<regex>
|
42
|
+
```
|
39
43
|
|
40
44
|
e.g. to run all compiler baseline tests:
|
41
45
|
|
42
|
-
|
46
|
+
```Shell
|
47
|
+
jake runtests tests=compiler
|
48
|
+
```
|
43
49
|
|
44
|
-
or to run specifc test:tests\cases\compiler\2dArrays.ts
|
50
|
+
or to run specifc test: `tests\cases\compiler\2dArrays.ts`
|
45
51
|
|
46
|
-
|
52
|
+
```Shell
|
53
|
+
jake runtests tests=2dArrays
|
54
|
+
```
|
47
55
|
|
48
56
|
## Adding a Test
|
49
|
-
To add a new testcase, simply place a
|
57
|
+
To add a new testcase, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
|
50
58
|
|
51
|
-
These files support metadata tags in the format
|
59
|
+
These files support metadata tags in the format `// @metaDataName: value`. The supported names and values are:
|
52
60
|
|
53
|
-
* comments
|
54
|
-
* target
|
55
|
-
* out
|
56
|
-
* module
|
61
|
+
* `comments`, `sourcemap`, `noimplicitany`, `declaration`: true or false (corresponds to the compiler command-line options of the same name)
|
62
|
+
* `target`: ES3 or ES5 (same as compiler)
|
63
|
+
* `out`, outDir: path (same as compiler)
|
64
|
+
* `module`: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
|
65
|
+
* `fileName`: path
|
66
|
+
* These tags delimit sections of a file to be used as separate compilation units. They are useful for tests relating to modules. See below for examples.
|
57
67
|
|
58
|
-
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in tests\cases\conformance in an appropriately-named subfolder.
|
68
|
+
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
|
59
69
|
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
|
60
70
|
|
71
|
+
### Tests for multiple files
|
72
|
+
|
73
|
+
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
|
74
|
+
|
75
|
+
```TypeScript
|
76
|
+
// @fileName: file1.ts
|
77
|
+
export function f() {
|
78
|
+
}
|
79
|
+
|
80
|
+
// @fileName: file2.ts
|
81
|
+
import { f as g } from "file1";
|
82
|
+
|
83
|
+
var x = g();
|
84
|
+
```
|
85
|
+
|
86
|
+
One can also write a project test, but it is slightly more involved.
|
87
|
+
|
61
88
|
## Managing the Baselines
|
62
|
-
Compiler testcases generate baselines that track the emitted
|
89
|
+
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
|
63
90
|
|
64
91
|
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
|
65
92
|
|
66
|
-
|
93
|
+
```Shell
|
94
|
+
jake diff
|
95
|
+
```
|
67
96
|
|
68
97
|
After verifying that the changes in the baselines are correct, run
|
69
98
|
|
70
|
-
|
99
|
+
```Shell
|
100
|
+
jake baseline-accept
|
101
|
+
```
|
71
102
|
|
72
|
-
to establish the new baselines as the desired behavior. This will change the files in tests\baselines\reference
|
103
|
+
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
|
73
104
|
|
74
105
|
**Note** that baseline-accept should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.
|
@@ -0,0 +1,795 @@
|
|
1
|
+
// This file contains the build logic for the public repo
|
2
|
+
|
3
|
+
var fs = require("fs");
|
4
|
+
var os = require("os");
|
5
|
+
var path = require("path");
|
6
|
+
var child_process = require("child_process");
|
7
|
+
|
8
|
+
// Variables
|
9
|
+
var compilerDirectory = "src/compiler/";
|
10
|
+
var servicesDirectory = "src/services/";
|
11
|
+
var serverDirectory = "src/server/";
|
12
|
+
var harnessDirectory = "src/harness/";
|
13
|
+
var libraryDirectory = "src/lib/";
|
14
|
+
var scriptsDirectory = "scripts/";
|
15
|
+
var unittestsDirectory = "tests/cases/unittests/";
|
16
|
+
var docDirectory = "doc/";
|
17
|
+
|
18
|
+
var builtDirectory = "built/";
|
19
|
+
var builtLocalDirectory = "built/local/";
|
20
|
+
var LKGDirectory = "lib/";
|
21
|
+
|
22
|
+
var copyright = "CopyrightNotice.txt";
|
23
|
+
var thirdParty = "ThirdPartyNoticeText.txt";
|
24
|
+
|
25
|
+
// add node_modules to path so we don't need global modules, prefer the modules by adding them first
|
26
|
+
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
|
27
|
+
if (process.env.path !== undefined) {
|
28
|
+
process.env.path = nodeModulesPathPrefix + process.env.path;
|
29
|
+
} else if (process.env.PATH !== undefined) {
|
30
|
+
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
|
31
|
+
}
|
32
|
+
|
33
|
+
var compilerSources = [
|
34
|
+
"core.ts",
|
35
|
+
"sys.ts",
|
36
|
+
"types.ts",
|
37
|
+
"scanner.ts",
|
38
|
+
"parser.ts",
|
39
|
+
"utilities.ts",
|
40
|
+
"binder.ts",
|
41
|
+
"checker.ts",
|
42
|
+
"declarationEmitter.ts",
|
43
|
+
"emitter.ts",
|
44
|
+
"program.ts",
|
45
|
+
"commandLineParser.ts",
|
46
|
+
"tsc.ts",
|
47
|
+
"diagnosticInformationMap.generated.ts"
|
48
|
+
].map(function (f) {
|
49
|
+
return path.join(compilerDirectory, f);
|
50
|
+
});
|
51
|
+
|
52
|
+
var servicesSources = [
|
53
|
+
"core.ts",
|
54
|
+
"sys.ts",
|
55
|
+
"types.ts",
|
56
|
+
"scanner.ts",
|
57
|
+
"parser.ts",
|
58
|
+
"utilities.ts",
|
59
|
+
"binder.ts",
|
60
|
+
"checker.ts",
|
61
|
+
"declarationEmitter.ts",
|
62
|
+
"emitter.ts",
|
63
|
+
"program.ts",
|
64
|
+
"commandLineParser.ts",
|
65
|
+
"diagnosticInformationMap.generated.ts"
|
66
|
+
].map(function (f) {
|
67
|
+
return path.join(compilerDirectory, f);
|
68
|
+
}).concat([
|
69
|
+
"breakpoints.ts",
|
70
|
+
"navigateTo.ts",
|
71
|
+
"navigationBar.ts",
|
72
|
+
"outliningElementsCollector.ts",
|
73
|
+
"patternMatcher.ts",
|
74
|
+
"services.ts",
|
75
|
+
"shims.ts",
|
76
|
+
"signatureHelp.ts",
|
77
|
+
"utilities.ts",
|
78
|
+
"formatting/formatting.ts",
|
79
|
+
"formatting/formattingContext.ts",
|
80
|
+
"formatting/formattingRequestKind.ts",
|
81
|
+
"formatting/formattingScanner.ts",
|
82
|
+
"formatting/references.ts",
|
83
|
+
"formatting/rule.ts",
|
84
|
+
"formatting/ruleAction.ts",
|
85
|
+
"formatting/ruleDescriptor.ts",
|
86
|
+
"formatting/ruleFlag.ts",
|
87
|
+
"formatting/ruleOperation.ts",
|
88
|
+
"formatting/ruleOperationContext.ts",
|
89
|
+
"formatting/rules.ts",
|
90
|
+
"formatting/rulesMap.ts",
|
91
|
+
"formatting/rulesProvider.ts",
|
92
|
+
"formatting/smartIndenter.ts",
|
93
|
+
"formatting/tokenRange.ts"
|
94
|
+
].map(function (f) {
|
95
|
+
return path.join(servicesDirectory, f);
|
96
|
+
}));
|
97
|
+
|
98
|
+
var serverSources = [
|
99
|
+
"node.d.ts",
|
100
|
+
"editorServices.ts",
|
101
|
+
"protocol.d.ts",
|
102
|
+
"session.ts",
|
103
|
+
"server.ts"
|
104
|
+
].map(function (f) {
|
105
|
+
return path.join(serverDirectory, f);
|
106
|
+
}).concat(servicesSources);
|
107
|
+
|
108
|
+
var languageServiceLibrarySources = [
|
109
|
+
"editorServices.ts",
|
110
|
+
"protocol.d.ts",
|
111
|
+
"session.ts"
|
112
|
+
].map(function (f) {
|
113
|
+
return path.join(serverDirectory, f);
|
114
|
+
}).concat(servicesSources);
|
115
|
+
|
116
|
+
var harnessCoreSources = [
|
117
|
+
"harness.ts",
|
118
|
+
"sourceMapRecorder.ts",
|
119
|
+
"harnessLanguageService.ts",
|
120
|
+
"fourslash.ts",
|
121
|
+
"runnerbase.ts",
|
122
|
+
"compilerRunner.ts",
|
123
|
+
"typeWriter.ts",
|
124
|
+
"fourslashRunner.ts",
|
125
|
+
"projectsRunner.ts",
|
126
|
+
"loggedIO.ts",
|
127
|
+
"rwcRunner.ts",
|
128
|
+
"test262Runner.ts",
|
129
|
+
"runner.ts"
|
130
|
+
].map(function (f) {
|
131
|
+
return path.join(harnessDirectory, f);
|
132
|
+
});
|
133
|
+
|
134
|
+
var harnessSources = harnessCoreSources.concat([
|
135
|
+
"incrementalParser.ts",
|
136
|
+
"jsDocParsing.ts",
|
137
|
+
"services/colorization.ts",
|
138
|
+
"services/documentRegistry.ts",
|
139
|
+
"services/preProcessFile.ts",
|
140
|
+
"services/patternMatcher.ts",
|
141
|
+
"session.ts",
|
142
|
+
"versionCache.ts",
|
143
|
+
"convertToBase64.ts",
|
144
|
+
"transpile.ts",
|
145
|
+
"reuseProgramStructure.ts",
|
146
|
+
"cachingInServerLSHost.ts",
|
147
|
+
"moduleResolution.ts"
|
148
|
+
].map(function (f) {
|
149
|
+
return path.join(unittestsDirectory, f);
|
150
|
+
})).concat([
|
151
|
+
"protocol.d.ts",
|
152
|
+
"session.ts",
|
153
|
+
"client.ts",
|
154
|
+
"editorServices.ts",
|
155
|
+
].map(function (f) {
|
156
|
+
return path.join(serverDirectory, f);
|
157
|
+
}));
|
158
|
+
|
159
|
+
var librarySourceMap = [
|
160
|
+
{ target: "lib.core.d.ts", sources: ["core.d.ts"] },
|
161
|
+
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
|
162
|
+
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
|
163
|
+
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
|
164
|
+
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
|
165
|
+
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
|
166
|
+
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
|
167
|
+
];
|
168
|
+
|
169
|
+
var libraryTargets = librarySourceMap.map(function (f) {
|
170
|
+
return path.join(builtLocalDirectory, f.target);
|
171
|
+
});
|
172
|
+
|
173
|
+
// Prepends the contents of prefixFile to destinationFile
|
174
|
+
function prependFile(prefixFile, destinationFile) {
|
175
|
+
if (!fs.existsSync(prefixFile)) {
|
176
|
+
fail(prefixFile + " does not exist!");
|
177
|
+
}
|
178
|
+
if (!fs.existsSync(destinationFile)) {
|
179
|
+
fail(destinationFile + " failed to be created!");
|
180
|
+
}
|
181
|
+
var temp = "temptemp";
|
182
|
+
jake.cpR(prefixFile, temp, {silent: true});
|
183
|
+
fs.appendFileSync(temp, fs.readFileSync(destinationFile));
|
184
|
+
fs.renameSync(temp, destinationFile);
|
185
|
+
}
|
186
|
+
|
187
|
+
// concatenate a list of sourceFiles to a destinationFile
|
188
|
+
function concatenateFiles(destinationFile, sourceFiles) {
|
189
|
+
var temp = "temptemp";
|
190
|
+
// Copy the first file to temp
|
191
|
+
if (!fs.existsSync(sourceFiles[0])) {
|
192
|
+
fail(sourceFiles[0] + " does not exist!");
|
193
|
+
}
|
194
|
+
jake.cpR(sourceFiles[0], temp, {silent: true});
|
195
|
+
// append all files in sequence
|
196
|
+
for (var i = 1; i < sourceFiles.length; i++) {
|
197
|
+
if (!fs.existsSync(sourceFiles[i])) {
|
198
|
+
fail(sourceFiles[i] + " does not exist!");
|
199
|
+
}
|
200
|
+
fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i]));
|
201
|
+
}
|
202
|
+
// Move the file to the final destination
|
203
|
+
fs.renameSync(temp, destinationFile);
|
204
|
+
}
|
205
|
+
|
206
|
+
var useDebugMode = true;
|
207
|
+
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
|
208
|
+
var compilerFilename = "tsc.js";
|
209
|
+
/* Compiles a file from a list of sources
|
210
|
+
* @param outFile: the target file name
|
211
|
+
* @param sources: an array of the names of the source files
|
212
|
+
* @param prereqs: prerequisite tasks to compiling the file
|
213
|
+
* @param prefixes: a list of files to prepend to the target file
|
214
|
+
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
|
215
|
+
* @param noOutFile: true to compile without using --out
|
216
|
+
* @param generateDeclarations: true to compile using --declaration
|
217
|
+
* @param outDir: true to compile using --outDir
|
218
|
+
* @param keepComments: false to compile using --removeComments
|
219
|
+
* @param callback: a function to execute after the compilation process ends
|
220
|
+
*/
|
221
|
+
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
|
222
|
+
file(outFile, prereqs, function() {
|
223
|
+
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
|
224
|
+
var options = "--module commonjs --noImplicitAny --noEmitOnError";
|
225
|
+
|
226
|
+
// Keep comments when specifically requested
|
227
|
+
// or when in debug mode.
|
228
|
+
if (!(keepComments || useDebugMode)) {
|
229
|
+
options += " --removeComments";
|
230
|
+
}
|
231
|
+
|
232
|
+
if (generateDeclarations) {
|
233
|
+
options += " --declaration";
|
234
|
+
}
|
235
|
+
|
236
|
+
if (preserveConstEnums || useDebugMode) {
|
237
|
+
options += " --preserveConstEnums";
|
238
|
+
}
|
239
|
+
|
240
|
+
if (outDir) {
|
241
|
+
options += " --outDir " + outDir;
|
242
|
+
}
|
243
|
+
|
244
|
+
if (!noOutFile) {
|
245
|
+
options += " --out " + outFile;
|
246
|
+
}
|
247
|
+
|
248
|
+
if(noResolve) {
|
249
|
+
options += " --noResolve";
|
250
|
+
}
|
251
|
+
|
252
|
+
if (useDebugMode) {
|
253
|
+
options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
|
254
|
+
}
|
255
|
+
|
256
|
+
if (stripInternal) {
|
257
|
+
options += " --stripInternal"
|
258
|
+
}
|
259
|
+
|
260
|
+
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
|
261
|
+
cmd = cmd + sources.join(" ");
|
262
|
+
console.log(cmd + "\n");
|
263
|
+
|
264
|
+
var ex = jake.createExec([cmd]);
|
265
|
+
// Add listeners for output and error
|
266
|
+
ex.addListener("stdout", function(output) {
|
267
|
+
process.stdout.write(output);
|
268
|
+
});
|
269
|
+
ex.addListener("stderr", function(error) {
|
270
|
+
process.stderr.write(error);
|
271
|
+
});
|
272
|
+
ex.addListener("cmdEnd", function() {
|
273
|
+
if (!useDebugMode && prefixes && fs.existsSync(outFile)) {
|
274
|
+
for (var i in prefixes) {
|
275
|
+
prependFile(prefixes[i], outFile);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
if (callback) {
|
280
|
+
callback();
|
281
|
+
}
|
282
|
+
|
283
|
+
complete();
|
284
|
+
});
|
285
|
+
ex.addListener("error", function() {
|
286
|
+
fs.unlinkSync(outFile);
|
287
|
+
fail("Compilation of " + outFile + " unsuccessful");
|
288
|
+
});
|
289
|
+
ex.run();
|
290
|
+
}, {async: true});
|
291
|
+
}
|
292
|
+
|
293
|
+
// Prerequisite task for built directory and library typings
|
294
|
+
directory(builtLocalDirectory);
|
295
|
+
|
296
|
+
for (var i in libraryTargets) {
|
297
|
+
(function (i) {
|
298
|
+
var entry = librarySourceMap[i];
|
299
|
+
var target = libraryTargets[i];
|
300
|
+
var sources = [copyright].concat(entry.sources.map(function (s) {
|
301
|
+
return path.join(libraryDirectory, s);
|
302
|
+
}));
|
303
|
+
file(target, [builtLocalDirectory].concat(sources), function() {
|
304
|
+
concatenateFiles(target, sources);
|
305
|
+
});
|
306
|
+
})(i);
|
307
|
+
}
|
308
|
+
|
309
|
+
// Lib target to build the library files
|
310
|
+
desc("Builds the library targets");
|
311
|
+
task("lib", libraryTargets);
|
312
|
+
|
313
|
+
|
314
|
+
// Generate diagnostics
|
315
|
+
var processDiagnosticMessagesJs = path.join(scriptsDirectory, "processDiagnosticMessages.js");
|
316
|
+
var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnosticMessages.ts");
|
317
|
+
var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json");
|
318
|
+
var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts");
|
319
|
+
|
320
|
+
file(processDiagnosticMessagesTs);
|
321
|
+
|
322
|
+
// processDiagnosticMessages script
|
323
|
+
compileFile(processDiagnosticMessagesJs,
|
324
|
+
[processDiagnosticMessagesTs],
|
325
|
+
[processDiagnosticMessagesTs],
|
326
|
+
[],
|
327
|
+
/*useBuiltCompiler*/ false);
|
328
|
+
|
329
|
+
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
|
330
|
+
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
|
331
|
+
var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
|
332
|
+
console.log(cmd);
|
333
|
+
var ex = jake.createExec([cmd]);
|
334
|
+
// Add listeners for output and error
|
335
|
+
ex.addListener("stdout", function(output) {
|
336
|
+
process.stdout.write(output);
|
337
|
+
});
|
338
|
+
ex.addListener("stderr", function(error) {
|
339
|
+
process.stderr.write(error);
|
340
|
+
});
|
341
|
+
ex.addListener("cmdEnd", function() {
|
342
|
+
complete();
|
343
|
+
});
|
344
|
+
ex.run();
|
345
|
+
}, {async: true});
|
346
|
+
|
347
|
+
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
|
348
|
+
task("generate-diagnostics", [diagnosticInfoMapTs]);
|
349
|
+
|
350
|
+
|
351
|
+
// Publish nightly
|
352
|
+
var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js");
|
353
|
+
var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts");
|
354
|
+
var packageJson = "package.json";
|
355
|
+
var programTs = path.join(compilerDirectory, "program.ts");
|
356
|
+
|
357
|
+
file(configureNightlyTs);
|
358
|
+
|
359
|
+
compileFile(/*outfile*/configureNightlyJs,
|
360
|
+
/*sources*/ [configureNightlyTs],
|
361
|
+
/*prereqs*/ [configureNightlyTs],
|
362
|
+
/*prefixes*/ [],
|
363
|
+
/*useBuiltCompiler*/ false,
|
364
|
+
/*noOutFile*/ false,
|
365
|
+
/*generateDeclarations*/ false,
|
366
|
+
/*outDir*/ undefined,
|
367
|
+
/*preserveConstEnums*/ undefined,
|
368
|
+
/*keepComments*/ false,
|
369
|
+
/*noResolve*/ false,
|
370
|
+
/*stripInternal*/ false);
|
371
|
+
|
372
|
+
task("setDebugMode", function() {
|
373
|
+
useDebugMode = true;
|
374
|
+
});
|
375
|
+
|
376
|
+
task("configure-nightly", [configureNightlyJs], function() {
|
377
|
+
var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs;
|
378
|
+
console.log(cmd);
|
379
|
+
exec(cmd);
|
380
|
+
}, { async: true });
|
381
|
+
|
382
|
+
desc("Configure, build, test, and publish the nightly release.");
|
383
|
+
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () {
|
384
|
+
var cmd = "npm publish --tag next";
|
385
|
+
console.log(cmd);
|
386
|
+
exec(cmd);
|
387
|
+
});
|
388
|
+
|
389
|
+
// Local target to build the compiler and services
|
390
|
+
var tscFile = path.join(builtLocalDirectory, compilerFilename);
|
391
|
+
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
|
392
|
+
|
393
|
+
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
|
394
|
+
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
395
|
+
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
|
396
|
+
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
|
397
|
+
var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts");
|
398
|
+
|
399
|
+
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
|
400
|
+
/*prefixes*/ [copyright],
|
401
|
+
/*useBuiltCompiler*/ true,
|
402
|
+
/*noOutFile*/ false,
|
403
|
+
/*generateDeclarations*/ true,
|
404
|
+
/*outDir*/ undefined,
|
405
|
+
/*preserveConstEnums*/ true,
|
406
|
+
/*keepComments*/ true,
|
407
|
+
/*noResolve*/ false,
|
408
|
+
/*stripInternal*/ true,
|
409
|
+
/*callback*/ function () {
|
410
|
+
jake.cpR(servicesFile, nodePackageFile, {silent: true});
|
411
|
+
|
412
|
+
prependFile(copyright, standaloneDefinitionsFile);
|
413
|
+
|
414
|
+
// Stanalone/web definition file using global 'ts' namespace
|
415
|
+
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
|
416
|
+
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
|
417
|
+
|
418
|
+
// Official node package definition file, pointed to by 'typings' in package.json
|
419
|
+
// Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module
|
420
|
+
var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;";
|
421
|
+
fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents);
|
422
|
+
|
423
|
+
// Node package definition file to be distributed without the package. Created by replacing
|
424
|
+
// 'ts' namespace with '"typescript"' as a module.
|
425
|
+
var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
|
426
|
+
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
|
427
|
+
});
|
428
|
+
|
429
|
+
|
430
|
+
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
|
431
|
+
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
|
432
|
+
|
433
|
+
var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
|
434
|
+
compileFile(
|
435
|
+
lsslFile,
|
436
|
+
languageServiceLibrarySources,
|
437
|
+
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
|
438
|
+
/*prefixes*/ [copyright],
|
439
|
+
/*useBuiltCompiler*/ true,
|
440
|
+
/*noOutFile*/ false,
|
441
|
+
/*generateDeclarations*/ true);
|
442
|
+
|
443
|
+
// Local target to build the language service server library
|
444
|
+
desc("Builds language service server library");
|
445
|
+
task("lssl", [lsslFile]);
|
446
|
+
|
447
|
+
// Local target to build the compiler and services
|
448
|
+
desc("Builds the full compiler and services");
|
449
|
+
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
|
450
|
+
|
451
|
+
// Local target to build only tsc.js
|
452
|
+
desc("Builds only the compiler");
|
453
|
+
task("tsc", ["generate-diagnostics", "lib", tscFile]);
|
454
|
+
|
455
|
+
// Local target to build the compiler and services
|
456
|
+
desc("Sets release mode flag");
|
457
|
+
task("release", function() {
|
458
|
+
useDebugMode = false;
|
459
|
+
});
|
460
|
+
|
461
|
+
// Set the default task to "local"
|
462
|
+
task("default", ["local"]);
|
463
|
+
|
464
|
+
|
465
|
+
// Cleans the built directory
|
466
|
+
desc("Cleans the compiler output, declare files, and tests");
|
467
|
+
task("clean", function() {
|
468
|
+
jake.rmRf(builtDirectory);
|
469
|
+
});
|
470
|
+
|
471
|
+
// Generate Markdown spec
|
472
|
+
var word2mdJs = path.join(scriptsDirectory, "word2md.js");
|
473
|
+
var word2mdTs = path.join(scriptsDirectory, "word2md.ts");
|
474
|
+
var specWord = path.join(docDirectory, "TypeScript Language Specification.docx");
|
475
|
+
var specMd = path.join(docDirectory, "spec.md");
|
476
|
+
|
477
|
+
file(word2mdTs);
|
478
|
+
|
479
|
+
// word2md script
|
480
|
+
compileFile(word2mdJs,
|
481
|
+
[word2mdTs],
|
482
|
+
[word2mdTs],
|
483
|
+
[],
|
484
|
+
/*useBuiltCompiler*/ false);
|
485
|
+
|
486
|
+
// The generated spec.md; built for the 'generate-spec' task
|
487
|
+
file(specMd, [word2mdJs, specWord], function () {
|
488
|
+
var specWordFullPath = path.resolve(specWord);
|
489
|
+
var cmd = "cscript //nologo " + word2mdJs + ' "' + specWordFullPath + '" ' + specMd;
|
490
|
+
console.log(cmd);
|
491
|
+
child_process.exec(cmd, function () {
|
492
|
+
complete();
|
493
|
+
});
|
494
|
+
}, {async: true});
|
495
|
+
|
496
|
+
|
497
|
+
desc("Generates a Markdown version of the Language Specification");
|
498
|
+
task("generate-spec", [specMd]);
|
499
|
+
|
500
|
+
|
501
|
+
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
|
502
|
+
desc("Makes a new LKG out of the built js files");
|
503
|
+
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
|
504
|
+
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile].concat(libraryTargets);
|
505
|
+
var missingFiles = expectedFiles.filter(function (f) {
|
506
|
+
return !fs.existsSync(f);
|
507
|
+
});
|
508
|
+
if (missingFiles.length > 0) {
|
509
|
+
fail("Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory +
|
510
|
+
". The following files are missing:\n" + missingFiles.join("\n"));
|
511
|
+
}
|
512
|
+
// Copy all the targets into the LKG directory
|
513
|
+
jake.mkdirP(LKGDirectory);
|
514
|
+
for (i in expectedFiles) {
|
515
|
+
jake.cpR(expectedFiles[i], LKGDirectory);
|
516
|
+
}
|
517
|
+
//var resourceDirectories = fs.readdirSync(builtLocalResourcesDirectory).map(function(p) { return path.join(builtLocalResourcesDirectory, p); });
|
518
|
+
//resourceDirectories.map(function(d) {
|
519
|
+
// jake.cpR(d, LKGResourcesDirectory);
|
520
|
+
//});
|
521
|
+
});
|
522
|
+
|
523
|
+
// Test directory
|
524
|
+
directory(builtLocalDirectory);
|
525
|
+
|
526
|
+
// Task to build the tests infrastructure using the built compiler
|
527
|
+
var run = path.join(builtLocalDirectory, "run.js");
|
528
|
+
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);
|
529
|
+
|
530
|
+
var internalTests = "internal/"
|
531
|
+
|
532
|
+
var localBaseline = "tests/baselines/local/";
|
533
|
+
var refBaseline = "tests/baselines/reference/";
|
534
|
+
|
535
|
+
var localRwcBaseline = path.join(internalTests, "baselines/rwc/local");
|
536
|
+
var refRwcBaseline = path.join(internalTests, "baselines/rwc/reference");
|
537
|
+
|
538
|
+
var localTest262Baseline = path.join(internalTests, "baselines/test262/local");
|
539
|
+
var refTest262Baseline = path.join(internalTests, "baselines/test262/reference");
|
540
|
+
|
541
|
+
desc("Builds the test infrastructure using the built compiler");
|
542
|
+
task("tests", ["local", run].concat(libraryTargets));
|
543
|
+
|
544
|
+
function exec(cmd, completeHandler, errorHandler) {
|
545
|
+
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
|
546
|
+
// Add listeners for output and error
|
547
|
+
ex.addListener("stdout", function(output) {
|
548
|
+
process.stdout.write(output);
|
549
|
+
});
|
550
|
+
ex.addListener("stderr", function(error) {
|
551
|
+
process.stderr.write(error);
|
552
|
+
});
|
553
|
+
ex.addListener("cmdEnd", function() {
|
554
|
+
if (completeHandler) {
|
555
|
+
completeHandler();
|
556
|
+
}
|
557
|
+
complete();
|
558
|
+
});
|
559
|
+
ex.addListener("error", function(e, status) {
|
560
|
+
if(errorHandler) {
|
561
|
+
errorHandler(e, status);
|
562
|
+
} else {
|
563
|
+
fail("Process exited with code " + status);
|
564
|
+
}
|
565
|
+
});
|
566
|
+
|
567
|
+
ex.run();
|
568
|
+
}
|
569
|
+
|
570
|
+
function cleanTestDirs() {
|
571
|
+
// Clean the local baselines directory
|
572
|
+
if (fs.existsSync(localBaseline)) {
|
573
|
+
jake.rmRf(localBaseline);
|
574
|
+
}
|
575
|
+
|
576
|
+
// Clean the local Rwc baselines directory
|
577
|
+
if (fs.existsSync(localRwcBaseline)) {
|
578
|
+
jake.rmRf(localRwcBaseline);
|
579
|
+
}
|
580
|
+
|
581
|
+
jake.mkdirP(localRwcBaseline);
|
582
|
+
jake.mkdirP(localTest262Baseline);
|
583
|
+
jake.mkdirP(localBaseline);
|
584
|
+
}
|
585
|
+
|
586
|
+
// used to pass data from jake command line directly to run.js
|
587
|
+
function writeTestConfigFile(tests, light, testConfigFile) {
|
588
|
+
console.log('Running test(s): ' + tests);
|
589
|
+
var testConfigContents = JSON.stringify({ test: [tests], light: light });
|
590
|
+
fs.writeFileSync('test.config', testConfigContents);
|
591
|
+
}
|
592
|
+
|
593
|
+
function deleteTemporaryProjectOutput() {
|
594
|
+
if (fs.existsSync(path.join(localBaseline, "projectOutput/"))) {
|
595
|
+
jake.rmRf(path.join(localBaseline, "projectOutput/"));
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
var testTimeout = 20000;
|
600
|
+
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.");
|
601
|
+
task("runtests", ["tests", builtLocalDirectory], function() {
|
602
|
+
cleanTestDirs();
|
603
|
+
host = "mocha"
|
604
|
+
tests = process.env.test || process.env.tests || process.env.t;
|
605
|
+
var light = process.env.light || false;
|
606
|
+
var testConfigFile = 'test.config';
|
607
|
+
if(fs.existsSync(testConfigFile)) {
|
608
|
+
fs.unlinkSync(testConfigFile);
|
609
|
+
}
|
610
|
+
|
611
|
+
if(tests || light) {
|
612
|
+
writeTestConfigFile(tests, light, testConfigFile);
|
613
|
+
}
|
614
|
+
|
615
|
+
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
616
|
+
testTimeout = 100000;
|
617
|
+
}
|
618
|
+
|
619
|
+
colors = process.env.colors || process.env.color
|
620
|
+
colors = colors ? ' --no-colors ' : ' --colors ';
|
621
|
+
tests = tests ? ' -g ' + tests : '';
|
622
|
+
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
|
623
|
+
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
|
624
|
+
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
|
625
|
+
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
626
|
+
console.log(cmd);
|
627
|
+
exec(cmd, deleteTemporaryProjectOutput);
|
628
|
+
}, {async: true});
|
629
|
+
|
630
|
+
desc("Generates code coverage data via instanbul");
|
631
|
+
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
|
632
|
+
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
|
633
|
+
console.log(cmd);
|
634
|
+
exec(cmd);
|
635
|
+
}, { async: true });
|
636
|
+
|
637
|
+
// Browser tests
|
638
|
+
var nodeServerOutFile = 'tests/webTestServer.js'
|
639
|
+
var nodeServerInFile = 'tests/webTestServer.ts'
|
640
|
+
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, /*noOutFile*/ true);
|
641
|
+
|
642
|
+
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
|
643
|
+
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
|
644
|
+
var cmd = 'browserify built/local/run.js -o built/local/bundle.js';
|
645
|
+
exec(cmd);
|
646
|
+
}, {async: true});
|
647
|
+
|
648
|
+
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
|
649
|
+
task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function() {
|
650
|
+
cleanTestDirs();
|
651
|
+
host = "node"
|
652
|
+
port = process.env.port || process.env.p || '8888';
|
653
|
+
browser = process.env.browser || process.env.b || "IE";
|
654
|
+
tests = process.env.test || process.env.tests || process.env.t;
|
655
|
+
var light = process.env.light || false;
|
656
|
+
var testConfigFile = 'test.config';
|
657
|
+
if(fs.existsSync(testConfigFile)) {
|
658
|
+
fs.unlinkSync(testConfigFile);
|
659
|
+
}
|
660
|
+
if(tests || light) {
|
661
|
+
writeTestConfigFile(tests, light, testConfigFile);
|
662
|
+
}
|
663
|
+
|
664
|
+
tests = tests ? tests : '';
|
665
|
+
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + tests
|
666
|
+
console.log(cmd);
|
667
|
+
exec(cmd);
|
668
|
+
}, {async: true});
|
669
|
+
|
670
|
+
function getDiffTool() {
|
671
|
+
var program = process.env['DIFF']
|
672
|
+
if (!program) {
|
673
|
+
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
|
674
|
+
}
|
675
|
+
return program;
|
676
|
+
}
|
677
|
+
|
678
|
+
// Baseline Diff
|
679
|
+
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
|
680
|
+
task('diff', function () {
|
681
|
+
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
|
682
|
+
console.log(cmd);
|
683
|
+
exec(cmd);
|
684
|
+
}, {async: true});
|
685
|
+
|
686
|
+
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
|
687
|
+
task('diff-rwc', function () {
|
688
|
+
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
|
689
|
+
console.log(cmd);
|
690
|
+
exec(cmd);
|
691
|
+
}, {async: true});
|
692
|
+
|
693
|
+
desc("Builds the test sources and automation in debug mode");
|
694
|
+
task("tests-debug", ["setDebugMode", "tests"]);
|
695
|
+
|
696
|
+
|
697
|
+
// Makes the test results the new baseline
|
698
|
+
desc("Makes the most recent test results the new baseline, overwriting the old baseline");
|
699
|
+
task("baseline-accept", function(hardOrSoft) {
|
700
|
+
if (!hardOrSoft || hardOrSoft == "hard") {
|
701
|
+
jake.rmRf(refBaseline);
|
702
|
+
fs.renameSync(localBaseline, refBaseline);
|
703
|
+
}
|
704
|
+
else if (hardOrSoft == "soft") {
|
705
|
+
var files = jake.readdirR(localBaseline);
|
706
|
+
for (var i in files) {
|
707
|
+
jake.cpR(files[i], refBaseline);
|
708
|
+
}
|
709
|
+
jake.rmRf(path.join(refBaseline, "local"));
|
710
|
+
}
|
711
|
+
});
|
712
|
+
|
713
|
+
desc("Makes the most recent rwc test results the new baseline, overwriting the old baseline");
|
714
|
+
task("baseline-accept-rwc", function() {
|
715
|
+
jake.rmRf(refRwcBaseline);
|
716
|
+
fs.renameSync(localRwcBaseline, refRwcBaseline);
|
717
|
+
});
|
718
|
+
|
719
|
+
desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline");
|
720
|
+
task("baseline-accept-test262", function() {
|
721
|
+
jake.rmRf(refTest262Baseline);
|
722
|
+
fs.renameSync(localTest262Baseline, refTest262Baseline);
|
723
|
+
});
|
724
|
+
|
725
|
+
|
726
|
+
// Webhost
|
727
|
+
var webhostPath = "tests/webhost/webtsc.ts";
|
728
|
+
var webhostJsPath = "tests/webhost/webtsc.js";
|
729
|
+
compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], /*useBuiltCompiler*/true);
|
730
|
+
|
731
|
+
desc("Builds the tsc web host");
|
732
|
+
task("webhost", [webhostJsPath], function() {
|
733
|
+
jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", {silent: true});
|
734
|
+
});
|
735
|
+
|
736
|
+
// Perf compiler
|
737
|
+
var perftscPath = "tests/perftsc.ts";
|
738
|
+
var perftscJsPath = "built/local/perftsc.js";
|
739
|
+
compileFile(perftscJsPath, [perftscPath], [tscFile, perftscPath, "tests/perfsys.ts"].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
|
740
|
+
desc("Builds augmented version of the compiler for perf tests");
|
741
|
+
task("perftsc", [perftscJsPath]);
|
742
|
+
|
743
|
+
// Instrumented compiler
|
744
|
+
var loggedIOpath = harnessDirectory + 'loggedIO.ts';
|
745
|
+
var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js';
|
746
|
+
file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
|
747
|
+
var temp = builtLocalDirectory + 'temp';
|
748
|
+
jake.mkdirP(temp);
|
749
|
+
var options = "--outdir " + temp + ' ' + loggedIOpath;
|
750
|
+
var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " ";
|
751
|
+
console.log(cmd + "\n");
|
752
|
+
var ex = jake.createExec([cmd]);
|
753
|
+
ex.addListener("cmdEnd", function() {
|
754
|
+
fs.renameSync(temp + '/harness/loggedIO.js', loggedIOJsPath);
|
755
|
+
jake.rmRf(temp);
|
756
|
+
complete();
|
757
|
+
});
|
758
|
+
ex.run();
|
759
|
+
}, {async: true});
|
760
|
+
|
761
|
+
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
|
762
|
+
var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js';
|
763
|
+
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
|
764
|
+
|
765
|
+
desc("Builds an instrumented tsc.js");
|
766
|
+
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {
|
767
|
+
var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename;
|
768
|
+
console.log(cmd);
|
769
|
+
var ex = jake.createExec([cmd]);
|
770
|
+
ex.addListener("cmdEnd", function() {
|
771
|
+
complete();
|
772
|
+
});
|
773
|
+
ex.run();
|
774
|
+
}, { async: true });
|
775
|
+
|
776
|
+
desc("Updates the sublime plugin's tsserver");
|
777
|
+
task("update-sublime", ["local", serverFile], function() {
|
778
|
+
jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/");
|
779
|
+
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
|
780
|
+
});
|
781
|
+
|
782
|
+
// if the codebase were free of linter errors we could make jake runtests
|
783
|
+
// run this task automatically
|
784
|
+
desc("Runs tslint on the compiler sources");
|
785
|
+
task("lint", [], function() {
|
786
|
+
function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }};
|
787
|
+
function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }};
|
788
|
+
|
789
|
+
var lintTargets = compilerSources.concat(harnessCoreSources);
|
790
|
+
for (var i in lintTargets) {
|
791
|
+
var f = lintTargets[i];
|
792
|
+
var cmd = 'tslint -c tslint.json ' + f;
|
793
|
+
exec(cmd, success(f), failure(f));
|
794
|
+
}
|
795
|
+
}, { async: true });
|