Skip to content

Commit 323b70f

Browse files
Add build-schema interface
1 parent 2f76dff commit 323b70f

File tree

2 files changed

+396
-2
lines changed

2 files changed

+396
-2
lines changed

server/src/buildSchema.ts

Lines changed: 392 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,392 @@
1+
// This file has been generated from https://raw.githubusercontent.com/rescript-lang/rescript-compiler/master/docs/docson/build-schema.json
2+
// with https://app.quicktype.io/
3+
4+
// To parse this data:
5+
//
6+
// import { Convert, BuildSchema } from "./file";
7+
//
8+
// const buildSchema = Convert.toBuildSchema(json);
9+
10+
/**
11+
* All paths are required to be in **Unix format** (foo/bar), the build system normalizes
12+
* them for other platforms internally
13+
*/
14+
export interface BuildSchema {
15+
/**
16+
* ReScript dependencies of the library, like in package.json. Currently searches in
17+
* `node_modules`
18+
*/
19+
"bs-dependencies"?: string[];
20+
/**
21+
* ReScript dev dependencies of the library, like in package.json. Currently searches in
22+
* `node_modules`
23+
*/
24+
"bs-dev-dependencies"?: string[];
25+
/**
26+
* (Not needed usually) external include directories, which will be applied `-I` to all
27+
* compilation units
28+
*/
29+
"bs-external-includes"?: string[];
30+
/**
31+
* Flags passed to bsc.exe
32+
*/
33+
"bsc-flags"?: string[] | BscFlagsObject;
34+
/**
35+
* Ignore generators, cut the dependency on generator tools
36+
*/
37+
"cut-generators"?: boolean;
38+
/**
39+
* (internal) Used by bsb to build to different targets: native (ocamlopt), bytecode
40+
* (ocamlc) or JS (bsc)
41+
*/
42+
entries?: TargetItems[];
43+
/**
44+
* Use the external stdlib library instead of the one shipped with the compiler package
45+
*/
46+
"external-stdlib"?: string;
47+
/**
48+
* Whether to generate the `.merlin` file for [Merlin](https://github.com/ocaml/merlin).
49+
* Default: true
50+
*/
51+
"generate-merlin"?: boolean;
52+
/**
53+
* (WIP) Pre defined rules
54+
*/
55+
generators?: RuleGenerator[];
56+
/**
57+
* gentype config, see cristianoc/genType for more details
58+
*/
59+
gentypeconfig?: GentypeSpecs;
60+
/**
61+
* a list of directories that bsb will not look into
62+
*/
63+
"ignored-dirs"?: string[];
64+
/**
65+
* (Experimental) post-processing hook. bsb will invoke `cmd ${file}` whenever a `${file}`
66+
* is changed
67+
*/
68+
"js-post-build"?: JSPostBuild;
69+
/**
70+
* Configuration for the JSX transformation.
71+
*/
72+
jsx?: JsxSpecs;
73+
/**
74+
* Package name
75+
*/
76+
name: string;
77+
/**
78+
* can be true/false or a customized name
79+
*/
80+
namespace?: boolean | string;
81+
/**
82+
* ReScript can currently output to [Commonjs](https://en.wikipedia.org/wiki/CommonJS), and
83+
* [ES6
84+
* modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)
85+
*/
86+
"package-specs"?:
87+
| Array<ModuleFormat | ModuleFormatObject>
88+
| ModuleFormat
89+
| ModuleFormatObject;
90+
/**
91+
* Those dependencies are pinned (since version 8.4)
92+
*/
93+
"pinned-dependencies"?: string[];
94+
/**
95+
* preprocessors to pass to compiler. The syntax is package_name/binary, for example:
96+
* `pp/syntax.exe`. Currenly searches in `node_modules`
97+
*/
98+
"pp-flags"?: string;
99+
/**
100+
* PPX macros to pass to compiler. The syntax is package_name/binary, for example:
101+
* `reason/reactjs_jsx_ppx_3.native`. Currenly searches in `node_modules`
102+
*/
103+
"ppx-flags"?: Array<string[] | string>;
104+
/**
105+
* Configure reanalyze, a static code analysis tool for ReScript.
106+
*/
107+
reanalyze?: Reanalyze;
108+
/**
109+
* ReScript comes with [Reason](http://reasonml.github.io/) by default. Specific
110+
* configurations here.
111+
*/
112+
reason?: ReasonSpecs;
113+
/**
114+
* Source code location
115+
*/
116+
sources: Array<SourcesObject | string> | SourcesObject | string;
117+
suffix?: SuffixSpec;
118+
/**
119+
* (Experimental) whether to use the OCaml standard library. Default: true
120+
*/
121+
"use-stdlib"?: boolean;
122+
/**
123+
* The semantic version of the ReScript library
124+
*/
125+
version?: string;
126+
/**
127+
* warning numbers and whether to turn it into error or not
128+
*/
129+
warnings?: Warnings;
130+
}
131+
132+
/**
133+
* (Not implemented yet)
134+
*/
135+
export interface BscFlagsObject {
136+
flags?: string[];
137+
kind?: BscFlagsKind;
138+
}
139+
140+
export enum BscFlagsKind {
141+
Append = "append",
142+
Prefix = "prefix",
143+
Reset = "reset",
144+
}
145+
146+
/**
147+
* (internal) Used by bsb to build to different targets: native (ocamlopt), bytecode
148+
* (ocamlc) or JS (bsc)
149+
*
150+
* A list of buildable targets
151+
*/
152+
export interface TargetItems {
153+
/**
154+
* The compiler to use for the target
155+
*/
156+
kind?: EntryKind;
157+
/**
158+
* Name of the main module used as entry point for this target. 'entry-point' isn't used
159+
* when this project is built as a dependency.
160+
*/
161+
main?: string;
162+
}
163+
164+
/**
165+
* The compiler to use for the target
166+
*/
167+
export enum EntryKind {
168+
Bytecode = "bytecode",
169+
JS = "js",
170+
Native = "native",
171+
}
172+
173+
/**
174+
* The shell command is running in *dev* time, and you generated could should be checked in,
175+
* the depedency is tracked properly during dev time,example: `{ "name" : "ocamllex",
176+
* "command" : "ocamllex.opt $in -o $out"}`
177+
*/
178+
export interface RuleGenerator {
179+
command?: string;
180+
name?: string;
181+
}
182+
183+
/**
184+
* gentype config, see cristianoc/genType for more details
185+
*
186+
* path to gentype, path resolution is similar to ReScript
187+
*/
188+
export interface GentypeSpecs {
189+
path?: string;
190+
}
191+
192+
/**
193+
* (Experimental) post-processing hook. bsb will invoke `cmd ${file}` whenever a `${file}`
194+
* is changed
195+
*/
196+
export interface JSPostBuild {
197+
cmd?: string;
198+
}
199+
200+
/**
201+
* Configuration for the JSX transformation.
202+
*/
203+
export interface JsxSpecs {
204+
/**
205+
* JSX transformation mode
206+
*/
207+
mode?: Mode;
208+
/**
209+
* JSX module, currently only support the React.
210+
*/
211+
module?: Module;
212+
/**
213+
* Build the given dependencies in JSX V3 compatibility mode.
214+
*/
215+
"v3-dependencies"?: string[];
216+
/**
217+
* Whether to apply the specific version of JSX PPX transformation
218+
*/
219+
version: number;
220+
}
221+
222+
/**
223+
* JSX transformation mode
224+
*/
225+
export enum Mode {
226+
Automatic = "automatic",
227+
Classic = "classic",
228+
}
229+
230+
/**
231+
* JSX module, currently only support the React.
232+
*/
233+
export enum Module {
234+
React = "react",
235+
}
236+
237+
/**
238+
* es6-global generate relative `require` paths instead of relying on NodeJS' module
239+
* resolution. Default: commonjs.
240+
*/
241+
export enum ModuleFormat {
242+
Commonjs = "commonjs",
243+
Es6 = "es6",
244+
Es6Global = "es6-global",
245+
}
246+
247+
export interface ModuleFormatObject {
248+
/**
249+
* Default: false.
250+
*/
251+
"in-source"?: boolean;
252+
module: ModuleFormat;
253+
suffix?: SuffixSpec;
254+
}
255+
256+
/**
257+
* suffix of generated js files, default to [.js]
258+
*/
259+
export enum SuffixSpec {
260+
BsCjs = ".bs.cjs",
261+
BsJS = ".bs.js",
262+
BsMjs = ".bs.mjs",
263+
Cjs = ".cjs",
264+
JS = ".js",
265+
Mjs = ".mjs",
266+
}
267+
268+
/**
269+
* Configure reanalyze, a static code analysis tool for ReScript.
270+
*/
271+
export interface Reanalyze {
272+
/**
273+
* The types of analysis to activate. `dce` means dead code analysis, `exception` means
274+
* exception analysis, and `termination` is to check for infinite loops.
275+
*/
276+
analysis?: Analysis[];
277+
/**
278+
* Paths for any folders you'd like to exclude from analysis. Useful for bindings and
279+
* similar. Example: `["src/bindings"]`.
280+
*/
281+
suppress?: string[];
282+
/**
283+
* Any specific paths inside suppressed folders that you want to unsuppress. Example:
284+
* ["src/bindings/SomeBinding.res"].
285+
*/
286+
unsuppress?: string[];
287+
}
288+
289+
export enum Analysis {
290+
Dce = "dce",
291+
Exception = "exception",
292+
Termination = "termination",
293+
}
294+
295+
/**
296+
* ReScript comes with [Reason](http://reasonml.github.io/) by default. Specific
297+
* configurations here.
298+
*/
299+
export interface ReasonSpecs {
300+
/**
301+
* Whether to apply the
302+
* [RescriptReact](https://github.com/rescript-lang/rescript-react)-specific JSX PPX
303+
* transformation.
304+
*/
305+
"react-jsx"?: number;
306+
}
307+
308+
export interface SourcesObject {
309+
/**
310+
* name of the directory
311+
*/
312+
dir: string;
313+
files?: string[] | FilesObject;
314+
/**
315+
* (WIP) Files generated in dev time
316+
*/
317+
generators?: BuildGenerator[];
318+
/**
319+
* Not implemented yet
320+
*/
321+
group?: GroupObject | string;
322+
"internal-depends"?: string[];
323+
/**
324+
* Default: export all modules. It is recommended for library developers to hide some
325+
* files/interfaces
326+
*/
327+
public?: string[] | PublicEnum;
328+
resources?: string[];
329+
subdirs?: Array<SourcesObject | string> | boolean | SourcesObject | string;
330+
type?: Type;
331+
}
332+
333+
export interface FilesObject {
334+
/**
335+
* Files to be excluded
336+
*/
337+
excludes?: string[];
338+
/**
339+
* Regex to glob the patterns, syntax is documented
340+
* [here](http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html), for better
341+
* incremental build performance, we'd suggest listing files explicitly
342+
*/
343+
"slow-re"?: string;
344+
}
345+
346+
/**
347+
* Note that we will add the directory path accordingly
348+
*/
349+
export interface BuildGenerator {
350+
edge?: string[];
351+
name?: string;
352+
}
353+
354+
export interface GroupObject {
355+
/**
356+
* When true, all subdirs are considered as a whole as dependency
357+
*/
358+
hierachy?: boolean;
359+
name?: string;
360+
}
361+
362+
export enum PublicEnum {
363+
All = "all",
364+
}
365+
366+
export enum Type {
367+
Dev = "dev",
368+
}
369+
370+
/**
371+
* warning numbers and whether to turn it into error or not
372+
*/
373+
export interface Warnings {
374+
error?: boolean | string;
375+
/**
376+
* Default: -40+6+7+27+32..39+44+45
377+
* [Here](https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec270) for the meanings of
378+
* the warning flags
379+
*/
380+
number?: string;
381+
}
382+
383+
// Converts JSON strings to/from your types
384+
export class Convert {
385+
public static toBuildSchema(json: string): BuildSchema {
386+
return JSON.parse(json);
387+
}
388+
389+
public static buildSchemaToJson(value: BuildSchema): string {
390+
return JSON.stringify(value);
391+
}
392+
}

0 commit comments

Comments
 (0)