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