Skip to content

Commit 2c17388

Browse files
authored
Remove Reason support, migrate sources to OCaml and update to latest ReScript parser (#82)
1 parent 84b4825 commit 2c17388

37 files changed

+480
-504
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
build:
1313
name: Build and test on ${{ matrix.os }}
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
os:
1718
- macos-latest
@@ -21,25 +22,35 @@ jobs:
2122
runs-on: ${{ matrix.os }}
2223

2324
steps:
24-
- name: Checkout repository
25-
uses: actions/checkout@v2
25+
- name: "Windows: Set git to use LF"
26+
if: runner.os == 'Windows'
27+
run: |
28+
git config --global core.autocrlf false
29+
git config --global core.eol lf
2630
27-
- name: Checkout submodules
28-
run: git submodule update --init --recursive
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
submodules: true
2935

30-
- name: Use Node.js 14
31-
uses: actions/setup-node@v2
36+
- name: Use Node.js 16
37+
uses: actions/setup-node@v3
3238
with:
33-
node-version: 14
39+
node-version: 16
3440

35-
- name: Use OCaml 4.06.1
41+
- name: Use OCaml 4.14.0
3642
uses: ocaml/setup-ocaml@v2
3743
with:
38-
ocaml-compiler: 4.06.1
44+
ocaml-compiler: 4.14.0
45+
opam-pin: false
46+
opam-depext: false
3947

4048
- name: OPAM install
4149
run: opam install . --deps-only --with-test
4250

51+
- name: Check format
52+
run: opam exec -- dune build @fmt
53+
4354
- name: Build
4455
run: opam exec -- dune build
4556

.ocamlformat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
profile = default
2+
version = 0.22.4
3+
4+
field-space = tight-decl
5+
break-cases = toplevel
6+
module-item-spacing = preserve
7+
cases-exp-indent = 2
8+
space-around-arrays = false
9+
space-around-lists = false
10+
space-around-records = false
11+
space-around-variants = false

.ocamlformat-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rescript_parser/*

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

bin/Extract.ml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
open Lib
2+
3+
let extract ~duplicatesAllowed paths =
4+
try
5+
let messages = Extractor.extract ~duplicatesAllowed paths in
6+
`List (messages |> List.map Message.toJson)
7+
|> Yojson.Basic.pretty_to_channel stdout;
8+
print_newline ()
9+
with
10+
| Extractor.PathNotFound path ->
11+
Printf.eprintf "Error: file or directory does not exist: %s\n" path;
12+
exit 1
13+
| Extractor.DuplicateMessageId id ->
14+
Printf.eprintf "Error: duplicate message id: %s\n" id;
15+
exit 2
16+
| Extractor.DefaultMessageNotMatching id ->
17+
Printf.eprintf
18+
"Error: duplicate message id: %s with different default messages\n" id;
19+
exit 3
20+
| exn ->
21+
Printf.eprintf "Unexpected error: %s\n" (Printexc.to_string exn);
22+
exit 10
23+
24+
type options = {showVersion: bool; paths: string list; duplicatesAllowed: bool}
25+
26+
let run () =
27+
let options =
28+
ref {showVersion = false; paths = []; duplicatesAllowed = false}
29+
in
30+
let processInputFilename filename =
31+
options := {!options with paths = filename :: !options.paths}
32+
in
33+
let allowDuplicates () =
34+
options := {!options with duplicatesAllowed = true}
35+
in
36+
let showVersion () = options := {!options with showVersion = true} in
37+
let args =
38+
[
39+
("-v", Arg.Unit showVersion, "shows the program version");
40+
( "--allow-duplicates",
41+
Arg.Unit allowDuplicates,
42+
"allows messages with identical `id` props if `defaultMessage` props \
43+
are identical as well" );
44+
]
45+
in
46+
let usage = "Usage: " ^ Sys.argv.(0) ^ " [path...]" in
47+
Arg.parse args processInputFilename usage;
48+
match !options with
49+
| {showVersion = true} -> print_endline Version.version
50+
| {paths = []} -> Arg.usage args usage
51+
| {paths; duplicatesAllowed} -> extract ~duplicatesAllowed paths
52+
53+
let () = run ()

bin/Extract.re

Lines changed: 0 additions & 60 deletions
This file was deleted.

bin/Version.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(*** GENERATED BY setVersion.js ***)
2+
3+
let version = "0.12.0 (ReScript f814061)"

bin/Version.re

Lines changed: 0 additions & 3 deletions
This file was deleted.

dune

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
(dirs bin lib syntax test)
2+
3+
(vendored_dirs rescript_parser)
4+
15
(env
2-
(dev
3-
(flags (:standard -w -9)))
4-
(release
5-
(flags (:standard -w -9))))
6+
(dev
7+
(flags
8+
(:standard -w -9)))
9+
(release
10+
(flags
11+
(:standard -w -9))))

dune-project

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
(depends
2929
(alcotest :with-test)
3030
(ocaml
31-
(= 4.06.1))
32-
(reason
33-
(= 3.7.0))
31+
(and
32+
(>= 4.10.0)
33+
(< 4.15.0)))
34+
(ocamlformat
35+
(= 0.22.4))
3436
(yojson
3537
(= 1.7.0))
3638
dune))

0 commit comments

Comments
 (0)