From 7d67364ffe43557a8d83bc1076a5232b167802a7 Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Thu, 29 May 2025 20:15:49 +0200 Subject: [PATCH 1/7] Add template based on dune and melange --- template/Makefile | 44 +++++++++++++++++++++++++++++++ template/app.re | 1 + template/bsconfig.json | 30 ---------------------- template/dune | 3 +++ template/dune-project | 3 +++ template/hello_exercism.opam | 16 ++++++++++++ template/package.json | 20 --------------- template/runtests.js | 50 ++++++++++++++++++++++++++++++++++++ template/src/Example.re | 0 template/test/dune | 6 +++++ template/test/lib_test.re | 9 +++++++ 11 files changed, 132 insertions(+), 50 deletions(-) create mode 100644 template/Makefile create mode 100644 template/app.re delete mode 100644 template/bsconfig.json create mode 100644 template/dune create mode 100644 template/dune-project create mode 100644 template/hello_exercism.opam delete mode 100644 template/package.json create mode 100644 template/runtests.js delete mode 100644 template/src/Example.re create mode 100644 template/test/dune create mode 100644 template/test/lib_test.re diff --git a/template/Makefile b/template/Makefile new file mode 100644 index 00000000..034921bb --- /dev/null +++ b/template/Makefile @@ -0,0 +1,44 @@ +DUNE = opam exec -- dune + +.DEFAULT_GOAL := help + +.PHONY: help +help: ## Print this help message + @echo "List of available make commands"; + @echo ""; + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'; + @echo ""; + +.PHONY: install +install: ## Install development dependencies + opam update + opam install -y . --deps-only + +.PHONY: test +test: ## Run built tests using node + $(DUNE) build + node runtests.js + +.PHONY: build +build: ## Build the project + $(DUNE) build + +.PHONY: build_verbose +build_verbose: ## Build the project + $(DUNE) build --verbose + +.PHONY: clean +clean: ## Clean build artifacts and other generated files + $(DUNE) clean + +.PHONY: format +format: ## Format the codebase with ocamlformat + $(DUNE) build @fmt --auto-promote + +.PHONY: format-check +format-check: ## Checks if format is correct + $(DUNE) build @fmt + +.PHONY: watch +watch: ## Watch for the filesystem and rebuild on every change + $(DUNE) build --watch diff --git a/template/app.re b/template/app.re new file mode 100644 index 00000000..5aa0003a --- /dev/null +++ b/template/app.re @@ -0,0 +1 @@ +let () = Js.log(Lib.name); 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 b/template/dune new file mode 100644 index 00000000..217632ac --- /dev/null +++ b/template/dune @@ -0,0 +1,3 @@ +(melange.emit + (target app) + (libraries lib)) diff --git a/template/dune-project b/template/dune-project new file mode 100644 index 00000000..90f638b5 --- /dev/null +++ b/template/dune-project @@ -0,0 +1,3 @@ +(lang dune 3.19) + +(using melange 0.1) diff --git a/template/hello_exercism.opam b/template/hello_exercism.opam new file mode 100644 index 00000000..13ccb7c2 --- /dev/null +++ b/template/hello_exercism.opam @@ -0,0 +1,16 @@ +opam-version: "2.0" +synopsis: "My Melange library" +description: "A library for Melange" +maintainer: [""] +authors: [""] +license: "XXX" +homepage: "https://github.com/your/project" +bug-reports: "https://github.com/your/project/issues" +depends: [ + "ocaml" + "reason" {>= "3.14.0"} + "dune" {>= "3.9"} + "melange" {>= "4.0.0"} + "melange-fest" {>= "0.1.0"} +] +dev-repo: "git+https://github.com/your/project.git" \ No newline at end of file diff --git a/template/package.json b/template/package.json deleted file mode 100644 index ba2b3b86..00000000 --- a/template/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "$(name)", - "version": "0.1.0", - "scripts": { - "build": "bsb -make-world", - "start": "bsb -make-world -w", - "clean": "bsb -clean-world", - "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" - } -} diff --git a/template/runtests.js b/template/runtests.js new file mode 100644 index 00000000..f4ed9cc0 --- /dev/null +++ b/template/runtests.js @@ -0,0 +1,50 @@ +const fs = require("fs"); +const path = require("path"); +const { spawnSync } = require("child_process"); + +const testDir = path.join( + __dirname, + "_build", + "default", + "test", + "test", + "test" +); + +function findTestFiles(dir) { + const testFiles = []; + const files = fs.readdirSync(dir); + + for (const file of files) { + const filePath = path.join(dir, file); + const stats = fs.statSync(filePath); + + if (stats.isDirectory()) { + testFiles.push(...findTestFiles(filePath)); // Recursive call for subdirectories + } else if (file.endsWith("_test.js")) { + testFiles.push(filePath); + } + } + + return testFiles; +} + +const testFiles = findTestFiles(testDir); + +if (testFiles.length === 0) { + console.log("No test files found."); + process.exit(0); +} + +console.log("Running tests:", testFiles); + +const result = spawnSync("node", ["--test", ...testFiles], { + stdio: "inherit", +}); + +if (result.error) { + console.error("Error running tests:", result.error); + process.exit(1); +} + +process.exit(result.status); diff --git a/template/src/Example.re b/template/src/Example.re deleted file mode 100644 index e69de29b..00000000 diff --git a/template/test/dune b/template/test/dune new file mode 100644 index 00000000..e6ed7c9c --- /dev/null +++ b/template/test/dune @@ -0,0 +1,6 @@ +(melange.emit + (target test) + (alias test) + (libraries melange-fest lib) + (preprocess + (pps melange.ppx))) diff --git a/template/test/lib_test.re b/template/test/lib_test.re new file mode 100644 index 00000000..8aadaedf --- /dev/null +++ b/template/test/lib_test.re @@ -0,0 +1,9 @@ +open Fest; + +test("1+1=2", () => + expect |> equal(1 + 1, 2) +); + +test("Hello world", () => + expect |> equal("World", Lib.name) +); From 8d34dc702dc656947615a93166c1b673136a24d3 Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Thu, 29 May 2025 20:40:17 +0200 Subject: [PATCH 2/7] Improvements to setup template - Add Readme with getting started docs - Remove runtests.js - Simplify a lot of stuff --- template/.gitignore | 36 ++++++++++++++++++++++++++ template/Makefile | 15 +++++++---- template/README.md | 31 ++++++++++++++++++++++ template/app.re | 2 +- template/hello_exercism.opam | 2 +- template/runtests.js | 50 ------------------------------------ 6 files changed, 79 insertions(+), 57 deletions(-) create mode 100644 template/.gitignore create mode 100644 template/README.md delete mode 100644 template/runtests.js 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/Makefile b/template/Makefile index 034921bb..c5b68950 100644 --- a/template/Makefile +++ b/template/Makefile @@ -10,18 +10,23 @@ help: ## Print this help message @echo ""; .PHONY: install -install: ## Install development dependencies +install: ## Install development and test dependencies opam update - opam install -y . --deps-only + opam install . --with-test --deps-only + +.PHONY: build +build: ## Build the project + $(DUNE) build .PHONY: test test: ## Run built tests using node $(DUNE) build - node runtests.js + node _build/default/test/test/test/lib_test.js -.PHONY: build -build: ## Build the project +.PHONY: run +run: ## Run the built JS script with node $(DUNE) build + node _build/default/app/app.js .PHONY: build_verbose build_verbose: ## Build the project diff --git a/template/README.md b/template/README.md new file mode 100644 index 00000000..b00f5755 --- /dev/null +++ b/template/README.md @@ -0,0 +1,31 @@ +How to setup the project locally: + +- Ensure you have [Node.js](https://nodejs.org/) installed + +- Setup a local opam switch to isolate the dependencies for this project +``` +opam switch create . 5.3.0 +``` + +- Install the required packages along with testing dependencies + +```bash +make install +``` + +- Build the project - produces JS files in the `_build` folder +```bash +make build +``` + +- Run the built JS script +```bash +make run +``` + +- Run the tests +```bash +make test +``` + +You can take a look at the `Makefile` to see the complete commands being run under the hood diff --git a/template/app.re b/template/app.re index 5aa0003a..39c6a935 100644 --- a/template/app.re +++ b/template/app.re @@ -1 +1 @@ -let () = Js.log(Lib.name); +let () = Js.log("Hello " ++ Lib.name); diff --git a/template/hello_exercism.opam b/template/hello_exercism.opam index 13ccb7c2..2f4e60f9 100644 --- a/template/hello_exercism.opam +++ b/template/hello_exercism.opam @@ -11,6 +11,6 @@ depends: [ "reason" {>= "3.14.0"} "dune" {>= "3.9"} "melange" {>= "4.0.0"} - "melange-fest" {>= "0.1.0"} + "melange-fest" {with-test} ] dev-repo: "git+https://github.com/your/project.git" \ No newline at end of file diff --git a/template/runtests.js b/template/runtests.js deleted file mode 100644 index f4ed9cc0..00000000 --- a/template/runtests.js +++ /dev/null @@ -1,50 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const { spawnSync } = require("child_process"); - -const testDir = path.join( - __dirname, - "_build", - "default", - "test", - "test", - "test" -); - -function findTestFiles(dir) { - const testFiles = []; - const files = fs.readdirSync(dir); - - for (const file of files) { - const filePath = path.join(dir, file); - const stats = fs.statSync(filePath); - - if (stats.isDirectory()) { - testFiles.push(...findTestFiles(filePath)); // Recursive call for subdirectories - } else if (file.endsWith("_test.js")) { - testFiles.push(filePath); - } - } - - return testFiles; -} - -const testFiles = findTestFiles(testDir); - -if (testFiles.length === 0) { - console.log("No test files found."); - process.exit(0); -} - -console.log("Running tests:", testFiles); - -const result = spawnSync("node", ["--test", ...testFiles], { - stdio: "inherit", -}); - -if (result.error) { - console.error("Error running tests:", result.error); - process.exit(1); -} - -process.exit(result.status); From e6261bb4bc6dcf91ce04c937d232057f5cc37a4e Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Fri, 30 May 2025 09:19:10 +0200 Subject: [PATCH 3/7] Run tests with dune --- template/Makefile | 3 +-- template/app.re | 2 +- template/dune-project | 2 +- template/test/dune | 14 ++++++++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/template/Makefile b/template/Makefile index c5b68950..f601a4b7 100644 --- a/template/Makefile +++ b/template/Makefile @@ -20,8 +20,7 @@ build: ## Build the project .PHONY: test test: ## Run built tests using node - $(DUNE) build - node _build/default/test/test/test/lib_test.js + $(DUNE) build @runtest --no-buffer .PHONY: run run: ## Run the built JS script with node diff --git a/template/app.re b/template/app.re index 39c6a935..17749397 100644 --- a/template/app.re +++ b/template/app.re @@ -1 +1 @@ -let () = Js.log("Hello " ++ Lib.name); +let () = Js.log("Hello " ++ Lib.name); diff --git a/template/dune-project b/template/dune-project index 90f638b5..fd89492f 100644 --- a/template/dune-project +++ b/template/dune-project @@ -1,3 +1,3 @@ -(lang dune 3.19) +(lang dune 3.17) (using melange 0.1) diff --git a/template/test/dune b/template/test/dune index e6ed7c9c..cb4c3ccd 100644 --- a/template/test/dune +++ b/template/test/dune @@ -1,6 +1,12 @@ (melange.emit - (target test) + (target node) (alias test) - (libraries melange-fest lib) - (preprocess - (pps melange.ppx))) + (libraries melange-fest lib)) + +(rule + (alias runtest) + (deps + (alias_rec test) + (:input ./node/test/lib_test.js)) + (action + (run node %{input}))) From a650f7f6d07c46ce7cd3918959213d743b8ca4cd Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Sun, 1 Jun 2025 12:31:28 +0200 Subject: [PATCH 4/7] Move to npm based workflow for template - move to jest for tests - run all commands from npm - add deps in dune-project [skip ci] --- template/Makefile | 48 ----------------------------------- template/README.md | 31 ---------------------- template/app.re | 1 - template/dune | 3 --- template/dune-project | 13 ++++++++++ template/hello_exercism.opam | 16 ------------ template/jest.config.js | 4 +++ template/package.json | 19 ++++++++++++++ template/test/Example_test.re | 8 ++++++ template/test/dune | 13 ++-------- template/test/lib_test.re | 9 ------- 11 files changed, 46 insertions(+), 119 deletions(-) delete mode 100644 template/Makefile delete mode 100644 template/README.md delete mode 100644 template/app.re delete mode 100644 template/dune delete mode 100644 template/hello_exercism.opam create mode 100644 template/jest.config.js create mode 100644 template/package.json create mode 100644 template/test/Example_test.re delete mode 100644 template/test/lib_test.re diff --git a/template/Makefile b/template/Makefile deleted file mode 100644 index f601a4b7..00000000 --- a/template/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -DUNE = opam exec -- dune - -.DEFAULT_GOAL := help - -.PHONY: help -help: ## Print this help message - @echo "List of available make commands"; - @echo ""; - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'; - @echo ""; - -.PHONY: install -install: ## Install development and test dependencies - opam update - opam install . --with-test --deps-only - -.PHONY: build -build: ## Build the project - $(DUNE) build - -.PHONY: test -test: ## Run built tests using node - $(DUNE) build @runtest --no-buffer - -.PHONY: run -run: ## Run the built JS script with node - $(DUNE) build - node _build/default/app/app.js - -.PHONY: build_verbose -build_verbose: ## Build the project - $(DUNE) build --verbose - -.PHONY: clean -clean: ## Clean build artifacts and other generated files - $(DUNE) clean - -.PHONY: format -format: ## Format the codebase with ocamlformat - $(DUNE) build @fmt --auto-promote - -.PHONY: format-check -format-check: ## Checks if format is correct - $(DUNE) build @fmt - -.PHONY: watch -watch: ## Watch for the filesystem and rebuild on every change - $(DUNE) build --watch diff --git a/template/README.md b/template/README.md deleted file mode 100644 index b00f5755..00000000 --- a/template/README.md +++ /dev/null @@ -1,31 +0,0 @@ -How to setup the project locally: - -- Ensure you have [Node.js](https://nodejs.org/) installed - -- Setup a local opam switch to isolate the dependencies for this project -``` -opam switch create . 5.3.0 -``` - -- Install the required packages along with testing dependencies - -```bash -make install -``` - -- Build the project - produces JS files in the `_build` folder -```bash -make build -``` - -- Run the built JS script -```bash -make run -``` - -- Run the tests -```bash -make test -``` - -You can take a look at the `Makefile` to see the complete commands being run under the hood diff --git a/template/app.re b/template/app.re deleted file mode 100644 index 17749397..00000000 --- a/template/app.re +++ /dev/null @@ -1 +0,0 @@ -let () = Js.log("Hello " ++ Lib.name); diff --git a/template/dune b/template/dune deleted file mode 100644 index 217632ac..00000000 --- a/template/dune +++ /dev/null @@ -1,3 +0,0 @@ -(melange.emit - (target app) - (libraries lib)) diff --git a/template/dune-project b/template/dune-project index fd89492f..b7764f79 100644 --- a/template/dune-project +++ b/template/dune-project @@ -1,3 +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/hello_exercism.opam b/template/hello_exercism.opam deleted file mode 100644 index 2f4e60f9..00000000 --- a/template/hello_exercism.opam +++ /dev/null @@ -1,16 +0,0 @@ -opam-version: "2.0" -synopsis: "My Melange library" -description: "A library for Melange" -maintainer: [""] -authors: [""] -license: "XXX" -homepage: "https://github.com/your/project" -bug-reports: "https://github.com/your/project/issues" -depends: [ - "ocaml" - "reason" {>= "3.14.0"} - "dune" {>= "3.9"} - "melange" {>= "4.0.0"} - "melange-fest" {with-test} -] -dev-repo: "git+https://github.com/your/project.git" \ 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/package.json b/template/package.json new file mode 100644 index 00000000..bf7c0c03 --- /dev/null +++ b/template/package.json @@ -0,0 +1,19 @@ +{ + "name": "$(name)", + "version": "0.1.0", + "scripts": { + "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" + }, + "author": "", + "license": "MIT", + "devDependencies": { + "jest": "^26.5.2" + } +} 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 index cb4c3ccd..caff88cf 100644 --- a/template/test/dune +++ b/template/test/dune @@ -1,12 +1,3 @@ (melange.emit - (target node) - (alias test) - (libraries melange-fest lib)) - -(rule - (alias runtest) - (deps - (alias_rec test) - (:input ./node/test/lib_test.js)) - (action - (run node %{input}))) + (target test) + (libraries melange-jest.jest lib)) diff --git a/template/test/lib_test.re b/template/test/lib_test.re deleted file mode 100644 index 8aadaedf..00000000 --- a/template/test/lib_test.re +++ /dev/null @@ -1,9 +0,0 @@ -open Fest; - -test("1+1=2", () => - expect |> equal(1 + 1, 2) -); - -test("Hello world", () => - expect |> equal("World", Lib.name) -); From dbee63b0c0c7fe20d408df4df8cf30812b08f36a Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Sun, 1 Jun 2025 12:35:39 +0200 Subject: [PATCH 5/7] Use lib as default solution folder [skip ci] --- .gitignore | 2 +- template/lib/Example.re | 1 + template/lib/dune | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 template/lib/Example.re create mode 100644 template/lib/dune 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/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)) From 50220e327758ac64cd7bc262d6cc32c2678dacec Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Sun, 1 Jun 2025 13:00:33 +0200 Subject: [PATCH 6/7] Update and simplify new exercise script [skip ci] --- bin/new-exercise.sh | 3 --- template/package.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/new-exercise.sh b/bin/new-exercise.sh index d603c081..54e9fa55 100755 --- a/bin/new-exercise.sh +++ b/bin/new-exercise.sh @@ -6,6 +6,3 @@ cp -r ./template ./exercises mv ./exercises/template ./exercises/$1 -find ./exercises/$1/ -type f | xargs sed -i "s/"'$(name)'"/$1/g" -test_file=`echo $1_test.re | sed -e "s/\b\(.\)/\u\1/"` -touch ./exercises/$1/__tests__/$test_file diff --git a/template/package.json b/template/package.json index bf7c0c03..1ce77a7f 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { - "name": "$(name)", + "name": "exercism-reasonml", "version": "0.1.0", "scripts": { "dune": "opam exec -- dune", From f2f54d3e0981fa2c426025a388f4b058c904250f Mon Sep 17 00:00:00 2001 From: Kevin Gathuku Date: Mon, 2 Jun 2025 13:37:29 +0000 Subject: [PATCH 7/7] Fixes to new exercise template --- bin/new-exercise.sh | 5 +++++ template/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/new-exercise.sh b/bin/new-exercise.sh index 54e9fa55..2c523a11 100755 --- a/bin/new-exercise.sh +++ b/bin/new-exercise.sh @@ -6,3 +6,8 @@ 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/"` +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/package.json b/template/package.json index 1ce77a7f..bf7c0c03 100644 --- a/template/package.json +++ b/template/package.json @@ -1,5 +1,5 @@ { - "name": "exercism-reasonml", + "name": "$(name)", "version": "0.1.0", "scripts": { "dune": "opam exec -- dune",