-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
Copy pathtsbuild.ts
183 lines (164 loc) · 5.2 KB
/
tsbuild.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import {
combinePaths,
Extension,
fileExtensionIs,
Path,
ResolvedConfigFileName,
} from "./_namespaces/ts.js";
/** @internal */
export enum UpToDateStatusType {
Unbuildable,
UpToDate,
/**
* The project appears out of date because its upstream inputs are newer than its outputs,
* but all of its outputs are actually newer than the previous identical outputs of its (.d.ts) inputs.
* This means we can Pseudo-build (just touch timestamps), as if we had actually built this project.
*/
UpToDateWithUpstreamTypes,
OutputMissing,
ErrorReadingFile,
OutOfDateWithSelf,
OutOfDateWithUpstream,
OutOfDateBuildInfoWithPendingEmit,
OutOfDateBuildInfoWithErrors,
OutOfDateOptions,
OutOfDateRoots,
UpstreamOutOfDate,
UpstreamBlocked,
ComputingUpstream,
TsVersionOutputOfDate,
UpToDateWithInputFileText,
/**
* Projects with no outputs (i.e. "solution" files)
*/
ContainerOnly,
ForceBuild,
}
/** @internal */
export type UpToDateStatus =
| Status.Unbuildable
| Status.UpToDate
| Status.OutputMissing
| Status.ErrorReadingFile
| Status.OutOfDateWithSelf
| Status.OutOfDateWithUpstream
| Status.OutOfDateBuildInfo
| Status.OutOfDateRoots
| Status.UpstreamOutOfDate
| Status.UpstreamBlocked
| Status.ComputingUpstream
| Status.TsVersionOutOfDate
| Status.ContainerOnly
| Status.ForceBuild;
/** @internal */
export namespace Status {
/**
* The project can't be built at all in its current state. For example,
* its config file cannot be parsed, or it has a syntax error or missing file
*/
export interface Unbuildable {
type: UpToDateStatusType.Unbuildable;
reason: string;
}
/**
* This project doesn't have any outputs, so "is it up to date" is a meaningless question.
*/
export interface ContainerOnly {
type: UpToDateStatusType.ContainerOnly;
}
/**
* The project is up to date with respect to its inputs.
* We track what the newest input file is.
*/
export interface UpToDate {
type:
| UpToDateStatusType.UpToDate
| UpToDateStatusType.UpToDateWithUpstreamTypes
| UpToDateStatusType.UpToDateWithInputFileText;
newestInputFileTime?: Date;
newestInputFileName?: string;
oldestOutputFileName: string;
}
/**
* One or more of the outputs of the project does not exist.
*/
export interface OutputMissing {
type: UpToDateStatusType.OutputMissing;
/**
* The name of the first output file that didn't exist
*/
missingOutputFileName: string;
}
/** Error reading file */
export interface ErrorReadingFile {
type: UpToDateStatusType.ErrorReadingFile;
fileName: string;
}
/**
* One or more of the project's outputs is older than its newest input.
*/
export interface OutOfDateWithSelf {
type: UpToDateStatusType.OutOfDateWithSelf;
outOfDateOutputFileName: string;
newerInputFileName: string;
}
/**
* Buildinfo indicates that build is out of date
*/
export interface OutOfDateBuildInfo {
type:
| UpToDateStatusType.OutOfDateBuildInfoWithPendingEmit
| UpToDateStatusType.OutOfDateBuildInfoWithErrors
| UpToDateStatusType.OutOfDateOptions;
buildInfoFile: string;
}
export interface OutOfDateRoots {
type: UpToDateStatusType.OutOfDateRoots;
buildInfoFile: string;
inputFile: Path;
}
/**
* This project depends on an out-of-date project, so shouldn't be built yet
*/
export interface UpstreamOutOfDate {
type: UpToDateStatusType.UpstreamOutOfDate;
upstreamProjectName: string;
}
/**
* This project depends an upstream project with build errors
*/
export interface UpstreamBlocked {
type: UpToDateStatusType.UpstreamBlocked;
upstreamProjectName: string;
upstreamProjectBlocked: boolean;
}
/**
* Computing status of upstream projects referenced
*/
export interface ComputingUpstream {
type: UpToDateStatusType.ComputingUpstream;
}
export interface TsVersionOutOfDate {
type: UpToDateStatusType.TsVersionOutputOfDate;
version: string;
}
/**
* One or more of the project's outputs is older than the newest output of
* an upstream project.
*/
export interface OutOfDateWithUpstream {
type: UpToDateStatusType.OutOfDateWithUpstream;
outOfDateOutputFileName: string;
newerProjectName: string;
}
export interface ForceBuild {
type: UpToDateStatusType.ForceBuild;
}
}
/** @internal */
export function resolveConfigFileProjectName(project: string): ResolvedConfigFileName {
if (fileExtensionIs(project, Extension.Json)) {
return project as ResolvedConfigFileName;
}
return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName;
}