Skip to content

Commit 26a60f5

Browse files
committed
refactor: rename config_error to manifest_error
1 parent 685301d commit 26a60f5

10 files changed

+109
-83
lines changed

jscomp/bsb/bsb_build_schemas.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ let warnings = "warnings"
7575
let number = "number"
7676
let error = "error"
7777
let suffix = "suffix"
78-
let gentypeconfig = "gentypeconfig"
79-
let language = "language"
78+
let gentype = "gentypeconfig"
79+
let gentype_language = "language"
80+
let gentype_module = "module"
81+
let gentype_module_resolution = "moduleResolution"
82+
let gentype_export_interfaces = "exportInterfaces"
83+
let gentype_generated_file_extension = "moduleResolution"
8084
let path = "path"
8185
let ignored_dirs = "ignored-dirs"
8286

83-
let uncurried = "uncurried"
87+
let uncurried = "uncurried"

jscomp/bsb/bsb_build_util.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ let extract_pinned_dependencies (map : Ext_json_types.t Map_string.t) : Set_stri
151151
| None -> Set_string.empty
152152
| Some (Arr { content }) ->
153153
Set_string.of_list (get_list_string content)
154-
| Some config -> Bsb_exception.config_error config "expect an array of string"
154+
| Some manifest -> Bsb_exception.manifest_error manifest "expect an array of string"
155155

156156
let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list)
157157
~(top : top) (dir : string) (queue : _ Queue.t) ~pinned_dependencies =

jscomp/bsb/bsb_config_interpret.ml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ let extract_package_name_and_namespace (map : json_map) : string * string option
4444
=
4545
let package_name =
4646
match map.?(Bsb_build_schemas.name) with
47-
| Some (Str { str = "_" } as config) ->
48-
Bsb_exception.config_error config "_ is a reserved package name"
47+
| Some (Str { str = "_" } as manifest) ->
48+
Bsb_exception.manifest_error manifest "_ is a reserved package name"
4949
| Some (Str { str = name }) -> name
50-
| Some config ->
51-
Bsb_exception.config_error config "name expect a string field"
50+
| Some manifest ->
51+
Bsb_exception.manifest_error manifest "name expect a string field"
5252
| None -> Bsb_exception.invalid_spec "field name is required"
5353
in
5454
let namespace =
@@ -59,8 +59,8 @@ let extract_package_name_and_namespace (map : json_map) : string * string option
5959
| Some (Str { str }) ->
6060
(*TODO : check the validity of namespace *)
6161
Some (Ext_namespace.namespace_of_package_name str)
62-
| Some x ->
63-
Bsb_exception.config_error x "namespace field expects string or boolean"
62+
| Some manifest ->
63+
Bsb_exception.manifest_error manifest "namespace field expects string or boolean"
6464
in
6565
(package_name, namespace)
6666

@@ -89,33 +89,33 @@ let check_stdlib (map : json_map) : bool =
8989
| None | Some _ -> true
9090

9191
let extract_gentype_config (map : json_map) : Bsb_config_types.gentype_config =
92-
match map.?(Bsb_build_schemas.gentypeconfig) with
92+
match map.?(Bsb_build_schemas.gentype) with
9393
| None -> false
9494
| Some (Obj _) -> true
95-
| Some config ->
96-
Bsb_exception.config_error config "gentypeconfig expect an object"
95+
| Some manifest ->
96+
Bsb_exception.manifest_error manifest "gentypeconfig expect an object"
9797

9898
let extract_uncurried (map : json_map) : bool =
9999
match map.?(Bsb_build_schemas.uncurried) with
100100
| None -> true
101101
| Some (True _) -> true
102102
| Some (False _) -> false
103-
| Some config ->
104-
Bsb_exception.config_error config "uncurried expects one of: true, false."
103+
| Some manifest ->
104+
Bsb_exception.manifest_error manifest "uncurried expects one of: true, false."
105105

106106
let extract_string (map : json_map) (field : string) cb =
107107
match map.?(field) with
108108
| None -> None
109109
| Some (Str { str }) -> cb str
110-
| Some config -> Bsb_exception.config_error config (field ^ " expect a string")
110+
| Some manifest -> Bsb_exception.manifest_error manifest (field ^ " expect a string")
111111

112112
let extract_boolean (map : json_map) (field : string) (default : bool) : bool =
113113
match map.?(field) with
114114
| None -> default
115115
| Some (True _) -> true
116116
| Some (False _) -> false
117-
| Some config ->
118-
Bsb_exception.config_error config (field ^ " expect a boolean")
117+
| Some manifest ->
118+
Bsb_exception.manifest_error manifest (field ^ " expect a boolean")
119119

120120
let extract_reason_react_jsx (map : json_map) =
121121
let default : Bsb_config_types.reason_react_jsx option ref = ref None in
@@ -130,7 +130,7 @@ let extract_reason_react_jsx (map : json_map) =
130130
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo
131131
)
132132
| Some x ->
133-
Bsb_exception.config_error x
133+
Bsb_exception.manifest_error x
134134
"Unexpected input (expect a version number) for jsx, note \
135135
boolean is no longer allowed"
136136
| None -> ()) )
@@ -141,14 +141,14 @@ let extract_warning (map : json_map) =
141141
match map.?(Bsb_build_schemas.warnings) with
142142
| None -> Bsb_warning.use_default
143143
| Some (Obj { map }) -> Bsb_warning.from_map map
144-
| Some config -> Bsb_exception.config_error config "expect an object"
144+
| Some manifest -> Bsb_exception.manifest_error manifest "expect an object"
145145

146146
let extract_ignored_dirs (map : json_map) : Set_string.t =
147147
match map.?(Bsb_build_schemas.ignored_dirs) with
148148
| None -> Set_string.empty
149149
| Some (Arr { content }) ->
150150
Set_string.of_list (Bsb_build_util.get_list_string content)
151-
| Some config -> Bsb_exception.config_error config "expect an array of string"
151+
| Some manifest -> Bsb_exception.manifest_error manifest "expect an array of string"
152152

153153
let extract_generators (map : json_map) =
154154
let generators = ref Map_string.empty in
@@ -169,8 +169,8 @@ let extract_generators (map : json_map) =
169169
{| generators exepect format like { "name" : "cppo", "command" : "cppo $in -o $out"} |}
170170
)
171171
| _ -> acc)
172-
| Some config ->
173-
Bsb_exception.config_error config
172+
| Some manifest ->
173+
Bsb_exception.manifest_error manifest
174174
(Bsb_build_schemas.generators ^ " expect an array field"));
175175
!generators
176176

@@ -181,14 +181,14 @@ let extract_dependencies (map : json_map) cwd (field : string) :
181181
| Some (Arr { content = s }) ->
182182
Ext_list.map (Bsb_build_util.get_list_string s) (fun s ->
183183
resolve_package cwd (Bsb_pkg_types.string_as_package s))
184-
| Some config -> Bsb_exception.config_error config (field ^ " expect an array")
184+
| Some manifest -> Bsb_exception.manifest_error manifest (field ^ " expect an array")
185185

186186
(* return an empty array if not found *)
187187
let extract_string_list (map : json_map) (field : string) : string list =
188188
match map.?(field) with
189189
| None -> []
190190
| Some (Arr { content = s }) -> Bsb_build_util.get_list_string s
191-
| Some config -> Bsb_exception.config_error config (field ^ " expect an array")
191+
| Some manifest -> Bsb_exception.manifest_error manifest (field ^ " expect an array")
192192

193193
let extract_ppx (map : json_map) (field : string) ~(cwd : string) :
194194
Bsb_config_types.ppx list =
@@ -209,12 +209,12 @@ let extract_ppx (map : json_map) (field : string) ~(cwd : string) :
209209
| Arr { content } -> (
210210
let xs = Bsb_build_util.get_list_string content in
211211
match xs with
212-
| [] -> Bsb_exception.config_error x " empty array is not allowed"
212+
| [] -> Bsb_exception.manifest_error x " empty array is not allowed"
213213
| name :: args -> { Bsb_config_types.name = resolve name; args })
214-
| config ->
215-
Bsb_exception.config_error config
214+
| manifest ->
215+
Bsb_exception.manifest_error manifest
216216
(field ^ "expect each item to be either string or array"))
217-
| Some config -> Bsb_exception.config_error config (field ^ " expect an array")
217+
| Some manifest -> Bsb_exception.manifest_error manifest (field ^ " expect an array")
218218

219219
let extract_js_post_build (map : json_map) cwd : string option =
220220
let js_post_build_cmd = ref None in

jscomp/bsb/bsb_exception.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
type error =
2626
| Package_not_found of Bsb_pkg_types.t * string option (* json file *)
27-
| Json_config of Ext_position.t * string
27+
| Json_manifest of Ext_position.t * string
2828
| Invalid_json of string
2929
| Invalid_spec of string
3030
| Conflict_module of string * string * string
@@ -68,7 +68,7 @@ let print (fmt : Format.formatter) (x : error) =
6868
@{<error>Error:@} package @{<error>%s@} not found or built %s\n\
6969
- Did you install it?\n\
7070
- If you did, did you run `rescript build -with-deps`?" name in_json
71-
| Json_config (pos, s) ->
71+
| Json_manifest (pos, s) ->
7272
Format.fprintf fmt
7373
"File %S, line %d:\n\
7474
@{<error>Error:@} %s \n\
@@ -89,12 +89,12 @@ let no_implementation modname = error (No_implementation modname)
8989
let not_consistent modname = error (Not_consistent modname)
9090

9191
let errorf ~loc fmt =
92-
Format.ksprintf (fun s -> error (Json_config (loc, s))) fmt
92+
Format.ksprintf (fun s -> error (Json_manifest (loc, s))) fmt
9393

94-
let config_error config fmt =
95-
let loc = Ext_json.loc_of config in
94+
let manifest_error manifest fmt =
95+
let loc = Ext_json.loc_of manifest in
9696

97-
error (Json_config (loc, fmt))
97+
error (Json_manifest (loc, fmt))
9898

9999
let invalid_spec s = error (Invalid_spec s)
100100

jscomp/bsb/bsb_exception.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ val conflict_module : string -> string -> string -> exn
3737

3838
val errorf : loc:Ext_position.t -> ('a, unit, string, 'b) format4 -> 'a
3939

40-
val config_error : Ext_json_types.t -> string -> 'a
40+
val manifest_error : Ext_json_types.t -> string -> 'a
4141

4242
val invalid_spec : string -> 'a
4343

jscomp/bsb/bsb_jsx.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let from_map map =
4848
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo
4949
)
5050
| Some x ->
51-
Bsb_exception.config_error x
51+
Bsb_exception.manifest_error x
5252
"Unexpected input (expect a version number) for jsx version"
5353
| None -> ()) )
5454
|? ( Bsb_build_schemas.jsx,
@@ -60,7 +60,7 @@ let from_map map =
6060
| "react" -> module_ := Some React
6161
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx module %s" str)
6262
| Some x ->
63-
Bsb_exception.config_error x
63+
Bsb_exception.manifest_error x
6464
"Unexpected input (jsx module name) for jsx module"
6565
| None -> ()) )
6666
|? ( Bsb_build_schemas.jsx,
@@ -73,7 +73,7 @@ let from_map map =
7373
| "automatic" -> mode := Some Automatic
7474
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx mode %s" str)
7575
| Some x ->
76-
Bsb_exception.config_error x
76+
Bsb_exception.manifest_error x
7777
"Unexpected input (expect classic or automatic) for jsx mode"
7878
| None -> ()) )
7979
|? ( Bsb_build_schemas.jsx,
@@ -83,7 +83,7 @@ let from_map map =
8383
| Some (Arr { content }) ->
8484
v3_dependencies := get_list_string content
8585
| Some x ->
86-
Bsb_exception.config_error x
86+
Bsb_exception.manifest_error x
8787
"Unexpected input for jsx v3-dependencies"
8888
| None -> ()) )
8989
|> ignore;

0 commit comments

Comments
 (0)