diff --git a/.gitignore b/.gitignore index 0089ee8c..fd40f27d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ bin/configlet bin/configlet.exe .vscode -**/lib/ +**/lib/bs/ **/node_modules **/*.bs.js .merlin diff --git a/bin/new-exercise.sh b/bin/new-exercise.sh index d603c081..2c523a11 100755 --- a/bin/new-exercise.sh +++ b/bin/new-exercise.sh @@ -7,5 +7,7 @@ cp -r ./template ./exercises mv ./exercises/template ./exercises/$1 find ./exercises/$1/ -type f | xargs sed -i "s/"'$(name)'"/$1/g" +lib_file=`echo $1.re | sed -e "s/\b\(.\)/\u\1/"` test_file=`echo $1_test.re | sed -e "s/\b\(.\)/\u\1/"` -touch ./exercises/$1/__tests__/$test_file +mv ./exercises/$1/lib/Example.re ./exercises/$1/lib/$lib_file +mv ./exercises/$1/test/Example_test.re ./exercises/$1/test/$test_file diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 00000000..a8ec1ef1 --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,36 @@ +# Created by https://www.toptal.com/developers/gitignore/api/ocaml +# Edit at https://www.toptal.com/developers/gitignore?templates=ocaml + +### OCaml ### +*.annot +*.cmo +*.cma +*.cmi +*.a +*.o +*.cmx +*.cmxs +*.cmxa + +# ocamlbuild working directory +_build/ + +# ocamlbuild targets +*.byte +*.native + +# oasis generated files +setup.data +setup.log + +# Merlin configuring file for Vim and Emacs +.merlin + +# Dune generated files +*.install + +# Local OPAM switch +_opam/ + +# End of https://www.toptal.com/developers/gitignore/api/ocaml + diff --git a/template/bsconfig.json b/template/bsconfig.json deleted file mode 100644 index 600d2fb4..00000000 --- a/template/bsconfig.json +++ /dev/null @@ -1,30 +0,0 @@ -// This is the configuration file used by BuckleScript's build system bsb. Its documentation lives here: http://bucklescript.github.io/bucklescript/docson/#build-schema.json -// BuckleScript comes with its own parser for bsconfig.json, which is normal JSON, with the extra support of comments and trailing commas. -{ - "name": "$(name)", - "version": "0.1.0", - "sources": [ - { - "dir" : "src", - "subdirs" : true - }, - { - "dir": "__tests__", - "type": "dev" - } - ], - "package-specs": { - "module": "commonjs", - "in-source": true - }, - "suffix": ".bs.js", - "bs-dependencies": [ - // add your dependencies here. You'd usually install them normally through `npm install my-dependency`. If my-dependency has a bsconfig.json too, then everything will work seamlessly. - ], - "bs-dev-dependencies": ["@glennsl/bs-jest"], - "warnings": { - "error" : "+101" - }, - "namespace": true, - "refmt": 3 -} diff --git a/template/dune-project b/template/dune-project new file mode 100644 index 00000000..b7764f79 --- /dev/null +++ b/template/dune-project @@ -0,0 +1,16 @@ +(lang dune 3.17) + +(using melange 0.1) + +(package + (name exercism-template) + (synopsis "Exercism exercise template") + (description "") + (allow_empty) + (depends + (ocaml (= 5.1.1)) + (dune (>= 3.17)) + (melange (>= 4.0 )) + (reason (>= 3.15)) + (ocaml-lsp-server :dev) + (melange-jest :with-test))) \ No newline at end of file diff --git a/template/jest.config.js b/template/jest.config.js new file mode 100644 index 00000000..6fa6d5a3 --- /dev/null +++ b/template/jest.config.js @@ -0,0 +1,4 @@ +module.exports = { + rootDir: "./_build/default/test", + testMatch: ["**/*_test.js"], +}; diff --git a/template/lib/Example.re b/template/lib/Example.re new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/template/lib/Example.re @@ -0,0 +1 @@ + diff --git a/template/lib/dune b/template/lib/dune new file mode 100644 index 00000000..55c92131 --- /dev/null +++ b/template/lib/dune @@ -0,0 +1,4 @@ +(library + (name lib) + (modes melange) + (libraries melange melange.belt melange.js)) diff --git a/template/package.json b/template/package.json index ba2b3b86..bf7c0c03 100644 --- a/template/package.json +++ b/template/package.json @@ -2,19 +2,18 @@ "name": "$(name)", "version": "0.1.0", "scripts": { - "build": "bsb -make-world", - "start": "bsb -make-world -w", - "clean": "bsb -clean-world", + "dune": "opam exec -- dune", + "build": "npm run dune -- build", + "start": "npm run build -- --watch", + "clean": "npm run dune -- clean", + "format": "npm run format:check -- --auto-promote", + "format:check": "npm run dune -- build @fmt", "test": "jest --watchAll", "test:ci": "jest --ci --bail --no-cache" }, - "keywords": [ - "BuckleScript" - ], "author": "", "license": "MIT", "devDependencies": { - "@glennsl/bs-jest": "^0.4.2", - "bs-platform": "^3.1.5" + "jest": "^26.5.2" } } diff --git a/template/src/Example.re b/template/src/Example.re deleted file mode 100644 index e69de29b..00000000 diff --git a/template/test/Example_test.re b/template/test/Example_test.re new file mode 100644 index 00000000..c9e0b1de --- /dev/null +++ b/template/test/Example_test.re @@ -0,0 +1,8 @@ +open Jest; +open Expect; + +describe("Example", () => { + test("basic", () => + expect(1 + 1) |> toEqual(2) + ) +}); diff --git a/template/test/dune b/template/test/dune new file mode 100644 index 00000000..caff88cf --- /dev/null +++ b/template/test/dune @@ -0,0 +1,3 @@ +(melange.emit + (target test) + (libraries melange-jest.jest lib))