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 OutOfDateWithSelf, 20 OutOfDateWithUpstream, 21 UpstreamOutOfDate, 22 UpstreamBlocked, 23 ComputingUpstream, 24 TsVersionOutputOfDate, 25 26 /** 27 * Projects with no outputs (i.e. "solution" files) 28 */ 29 ContainerOnly 30 } 31 32 export type UpToDateStatus = 33 | Status.Unbuildable 34 | Status.UpToDate 35 | Status.OutOfDateWithPrepend 36 | Status.OutputMissing 37 | Status.OutOfDateWithSelf 38 | Status.OutOfDateWithUpstream 39 | Status.UpstreamOutOfDate 40 | Status.UpstreamBlocked 41 | Status.ComputingUpstream 42 | Status.TsVersionOutOfDate 43 | Status.ContainerOnly; 44 45 export namespace Status { 46 /** 47 * The project can't be built at all in its current state. For example, 48 * its config file cannot be parsed, or it has a syntax error or missing file 49 */ 50 export interface Unbuildable { 51 type: UpToDateStatusType.Unbuildable; 52 reason: string; 53 } 54 55 /** 56 * This project doesn't have any outputs, so "is it up to date" is a meaningless question. 57 */ 58 export interface ContainerOnly { 59 type: UpToDateStatusType.ContainerOnly; 60 } 61 62 /** 63 * The project is up to date with respect to its inputs. 64 * We track what the newest input file is. 65 */ 66 export interface UpToDate { 67 type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; 68 newestInputFileTime?: Date; 69 newestInputFileName?: string; 70 newestDeclarationFileContentChangedTime?: Date; 71 newestOutputFileTime?: Date; 72 newestOutputFileName?: string; 73 oldestOutputFileName: string; 74 } 75 76 /** 77 * The project is up to date with respect to its inputs except for prepend output changed (no declaration file change in prepend). 78 */ 79 export interface OutOfDateWithPrepend { 80 type: UpToDateStatusType.OutOfDateWithPrepend; 81 outOfDateOutputFileName: string; 82 newerProjectName: string; 83 } 84 85 /** 86 * One or more of the outputs of the project does not exist. 87 */ 88 export interface OutputMissing { 89 type: UpToDateStatusType.OutputMissing; 90 /** 91 * The name of the first output file that didn't exist 92 */ 93 missingOutputFileName: string; 94 } 95 96 /** 97 * One or more of the project's outputs is older than its newest input. 98 */ 99 export interface OutOfDateWithSelf { 100 type: UpToDateStatusType.OutOfDateWithSelf; 101 outOfDateOutputFileName: string; 102 newerInputFileName: string; 103 } 104 105 /** 106 * This project depends on an out-of-date project, so shouldn't be built yet 107 */ 108 export interface UpstreamOutOfDate { 109 type: UpToDateStatusType.UpstreamOutOfDate; 110 upstreamProjectName: string; 111 } 112 113 /** 114 * This project depends an upstream project with build errors 115 */ 116 export interface UpstreamBlocked { 117 type: UpToDateStatusType.UpstreamBlocked; 118 upstreamProjectName: string; 119 upstreamProjectBlocked: boolean; 120 } 121 122 /** 123 * Computing status of upstream projects referenced 124 */ 125 export interface ComputingUpstream { 126 type: UpToDateStatusType.ComputingUpstream; 127 } 128 129 export interface TsVersionOutOfDate { 130 type: UpToDateStatusType.TsVersionOutputOfDate; 131 version: string; 132 } 133 134 /** 135 * One or more of the project's outputs is older than the newest output of 136 * an upstream project. 137 */ 138 export interface OutOfDateWithUpstream { 139 type: UpToDateStatusType.OutOfDateWithUpstream; 140 outOfDateOutputFileName: string; 141 newerProjectName: string; 142 } 143 } 144 145 export function resolveConfigFileProjectName(project: string): ResolvedConfigFileName { 146 if (fileExtensionIs(project, Extension.Json)) { 147 return project as ResolvedConfigFileName; 148 } 149 150 return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName; 151 } 152}