UNPKG

8.44 kBTypeScriptView Raw
1/// <reference types="node" />
2import FileRef from './file-ref';
3import FileFsRef from './file-fs-ref';
4export interface Env {
5 [name: string]: string | undefined;
6}
7export interface File {
8 type: string;
9 mode: number;
10 contentType?: string;
11 toStream: () => NodeJS.ReadableStream;
12 /**
13 * The absolute path to the file in the filesystem
14 */
15 fsPath?: string;
16}
17export interface Files {
18 [filePath: string]: File;
19}
20export interface Config {
21 [key: string]: string | string[] | boolean | number | {
22 [key: string]: string;
23 } | BuilderFunctions | undefined;
24 maxLambdaSize?: string;
25 includeFiles?: string | string[];
26 excludeFiles?: string | string[];
27 bundle?: boolean;
28 ldsflags?: string;
29 helpers?: boolean;
30 rust?: string;
31 debug?: boolean;
32 zeroConfig?: boolean;
33 import?: {
34 [key: string]: string;
35 };
36 functions?: BuilderFunctions;
37 outputDirectory?: string;
38 buildCommand?: string;
39 devCommand?: string;
40 framework?: string;
41 nodeVersion?: string;
42}
43export interface Meta {
44 isDev?: boolean;
45 devCacheDir?: string;
46 skipDownload?: boolean;
47 requestPath?: string | null;
48 filesChanged?: string[];
49 filesRemoved?: string[];
50 env?: Env;
51 buildEnv?: Env;
52}
53export interface AnalyzeOptions {
54 /**
55 * All source files of the project
56 */
57 files: {
58 [filePath: string]: FileRef;
59 };
60 /**
61 * Name of entrypoint file for this particular build job. Value
62 * `files[entrypoint]` is guaranteed to exist and be a valid File reference.
63 * `entrypoint` is always a discrete file and never a glob, since globs are
64 * expanded into separate builds at deployment time.
65 */
66 entrypoint: string;
67 /**
68 * A writable temporary directory where you are encouraged to perform your
69 * build process. This directory will be populated with the restored cache.
70 */
71 workPath: string;
72 /**
73 * An arbitrary object passed by the user in the build definition defined
74 * in `vercel.json`.
75 */
76 config: Config;
77}
78export interface BuildOptions {
79 /**
80 * All source files of the project
81 */
82 files: Files;
83 /**
84 * Name of entrypoint file for this particular build job. Value
85 * `files[entrypoint]` is guaranteed to exist and be a valid File reference.
86 * `entrypoint` is always a discrete file and never a glob, since globs are
87 * expanded into separate builds at deployment time.
88 */
89 entrypoint: string;
90 /**
91 * A writable temporary directory where you are encouraged to perform your
92 * build process. This directory will be populated with the restored cache.
93 */
94 workPath: string;
95 /**
96 * An arbitrary object passed by the user in the build definition defined
97 * in `vercel.json`.
98 */
99 config: Config;
100 /**
101 * Metadata related to the invoker of the builder, used by `vercel dev`.
102 * Builders may use the properties on this object to change behavior based
103 * on the build environment.
104 */
105 meta?: Meta;
106}
107export interface PrepareCacheOptions {
108 /**
109 * All source files of the project
110 */
111 files: Files;
112 /**
113 * Name of entrypoint file for this particular build job. Value
114 * `files[entrypoint]` is guaranteed to exist and be a valid File reference.
115 * `entrypoint` is always a discrete file and never a glob, since globs are
116 * expanded into separate builds at deployment time.
117 */
118 entrypoint: string;
119 /**
120 * A writable temporary directory where you are encouraged to perform your
121 * build process.
122 */
123 workPath: string;
124 /**
125 * A writable temporary directory where you can build a cache to use for
126 * the next run.
127 */
128 cachePath: string;
129 /**
130 * An arbitrary object passed by the user in the build definition defined
131 * in `vercel.json`.
132 */
133 config: Config;
134}
135export interface ShouldServeOptions {
136 /**
137 * A path string from a request.
138 */
139 requestPath: string;
140 /**
141 * Name of entrypoint file for this particular build job. Value
142 * `files[entrypoint]` is guaranteed to exist and be a valid File reference.
143 * `entrypoint` is always a discrete file and never a glob, since globs are
144 * expanded into separate builds at deployment time.
145 */
146 entrypoint: string;
147 /**
148 * All source files of the project
149 */
150 files: {
151 [path: string]: FileFsRef;
152 };
153 /**
154 * A writable temporary directory where you are encouraged to perform your
155 * build process. This directory will be populated with the restored cache.
156 */
157 workPath: string;
158 /**
159 * An arbitrary object passed by the user in the build definition defined
160 * in `vercel.json`.
161 */
162 config: Config;
163}
164/**
165 * `startDevServer()` is given the same parameters as `build()`.
166 */
167export declare type StartDevServerOptions = BuildOptions;
168export interface StartDevServerSuccess {
169 /**
170 * Port number where the dev server can be connected to, assumed to be running
171 * on `localhost`.
172 */
173 port: number;
174 /**
175 * Process ID number of the dev server. Useful for the `vercel dev` server to
176 * shut down the dev server once an HTTP request has been fulfilled.
177 */
178 pid: number;
179}
180/**
181 * `startDevServer()` may return `null` to opt-out of spawning a dev server for
182 * a given `entrypoint`.
183 */
184export declare type StartDevServerResult = StartDevServerSuccess | null;
185/**
186 * Credit to Iain Reid, MIT license.
187 * Source: https://gist.github.com/iainreid820/5c1cc527fe6b5b7dba41fec7fe54bf6e
188 */
189export declare namespace PackageJson {
190 /**
191 * An author or contributor
192 */
193 interface Author {
194 name: string;
195 email?: string;
196 homepage?: string;
197 }
198 /**
199 * A map of exposed bin commands
200 */
201 interface BinMap {
202 [commandName: string]: string;
203 }
204 /**
205 * A bugs link
206 */
207 interface Bugs {
208 email: string;
209 url: string;
210 }
211 interface Config {
212 name?: string;
213 config?: unknown;
214 }
215 /**
216 * A map of dependencies
217 */
218 interface DependencyMap {
219 [dependencyName: string]: string;
220 }
221 /**
222 * CommonJS package structure
223 */
224 interface Directories {
225 lib?: string;
226 bin?: string;
227 man?: string;
228 doc?: string;
229 example?: string;
230 }
231 interface Engines {
232 node?: string;
233 npm?: string;
234 }
235 interface PublishConfig {
236 registry?: string;
237 }
238 /**
239 * A project repository
240 */
241 interface Repository {
242 type: string;
243 url: string;
244 }
245 interface ScriptsMap {
246 [scriptName: string]: string;
247 }
248}
249export interface PackageJson {
250 readonly name?: string;
251 readonly version?: string;
252 readonly description?: string;
253 readonly keywords?: string[];
254 readonly homepage?: string;
255 readonly bugs?: string | PackageJson.Bugs;
256 readonly license?: string;
257 readonly author?: string | PackageJson.Author;
258 readonly contributors?: string[] | PackageJson.Author[];
259 readonly files?: string[];
260 readonly main?: string;
261 readonly bin?: string | PackageJson.BinMap;
262 readonly man?: string | string[];
263 readonly directories?: PackageJson.Directories;
264 readonly repository?: string | PackageJson.Repository;
265 readonly scripts?: PackageJson.ScriptsMap;
266 readonly config?: PackageJson.Config;
267 readonly dependencies?: PackageJson.DependencyMap;
268 readonly devDependencies?: PackageJson.DependencyMap;
269 readonly peerDependencies?: PackageJson.DependencyMap;
270 readonly optionalDependencies?: PackageJson.DependencyMap;
271 readonly bundledDependencies?: string[];
272 readonly engines?: PackageJson.Engines;
273 readonly os?: string[];
274 readonly cpu?: string[];
275 readonly preferGlobal?: boolean;
276 readonly private?: boolean;
277 readonly publishConfig?: PackageJson.PublishConfig;
278}
279export interface NodeVersion {
280 major: number;
281 range: string;
282 runtime: string;
283 discontinueDate?: Date;
284}
285export interface Builder {
286 use: string;
287 src: string;
288 config?: Config;
289}
290export interface BuilderFunctions {
291 [key: string]: {
292 memory?: number;
293 maxDuration?: number;
294 runtime?: string;
295 includeFiles?: string;
296 excludeFiles?: string;
297 };
298}