Hi,
I’m happy to announce a new version of Spin, the OCaml project generator.
This version comes with a lot of improvements. I’m joining the Changelog below, but I’ll highlight some of them here.
Spin as an Opam plugin
This version of Spin is available as an Opam plugin.
opam spin new cli, for instance, will generate a new CLI.
The hello command
This release comes with a brand new template targetted solely at first-time users.
The spin hello command will generate an hello world project where the development setup and directory structure are explained in the README.
Each file are extensively documented, so users can just open any file and learn by example.
If you’re onboarding new users, I’d be curious what’s your experience with opam spin hello!
Simplified templates
The templates have been simplified.
Some templates supported some very specific use cases, such as deploying a CLI on NPM. This is no longer the case and the focus for the official templates from now on will be to support the recommended setup (ie. the OCaml Platform) only.
Part of this simplification is also achieved by dropping the support for Reason and Esy. The previous templates will be available at (OCaml Templates · GitHub) with the reason- prefix.
I’ve extracted them already, but they will need some reworking before they are usable again.
Better prompts
The interactive prompts have been improved through a complete rewrite of inquire, the prompt library used in Spin.
I’ve tried to test the new prompts as much as possible, but if you encounter an issue with them, don’t hesitate to open an issue on Spin or Inquire.
Dream template
Not really part of this release, because this is a community template, but I have been working on a template for Dream, the new kid OCaml web framework scene, by @aantron.
To try it, you can run: opam spin new https://github.com/ocaml-templates/spin-dream.
It comes with a modern setup, including:
- TailwindCSS integrated with Dune
- Inter fonts
- Live reloading on file system change
- Turbolink setup
It’s a bit heavy for my taste at the moment, so I will work on making most of the features optionnal, but if you’re looking to start a new Dream app quickly, this might be useful.
Changelog
Here’s the complete Changelog.
Added
-
Added an
hellocommand to generate a tutorial project -
Added a
parse_binariesstanza that can betrueto force Spin to parse binary files -
Added a
raw_filesstanza that takes a list of file or glob expressions to instruct Spin to copy files instead of parsing them -
Added a new
c-bindingstemplate for C bindings usingctypes -
Added a new
jstemplate for javascript applications withjs_of_ocaml
Changed
-
Removed the
gensubcommand. The generators will come back with a much better workflow -
Dropped support for Esy and Reason. The templates are now using the recommended OCaml setup only. The previous templates are hosted at OCaml Templates · GitHub
-
Changed the templates to use the
ISClicense -
Increase version of
ocamlformatto0.18.0in templates -
Do not install merlin when installing dev dependencies in templates
-
Drop support for BuckleScript in PPX
-
Drop support for publishing on NPM for CLI and PPX templates
-
Update CI scripts to
ocaml/setup-ocaml@v2 -
Remove python dependency to serve documentation in Makefile
-
Inline release script in Makefile
-
Remove global
-open StdLabelsin templates -
The
spatemplate has been removed from the official templates and now lives at GitHub - ocaml-templates/spin-incr-dom: Spin project template for Incr_dom single-page-application with Js_of_ocaml -
Spin does not parse binary files by default anymore, they are simply copied to the destination folder
-
Use
teststanza for unit tests now that Alcotest prints colors by default -
Remove unused flags defined in the root’s
dunefile
Fixes
-
The project generation will now fail before the configurations prompt if the output directory is not empty
-
By default, Spin now creates a local switch for the generated projects. This can be changed with
spin config, or by setting the env variableSPIN_CREATE_SWITCH=false -
Fix an CLI incompatibility between
opam.2.0.Xandopam.2.1.Xthat made Spin unusable with the former.
I’m also taking the occasion to mention that I am looking for a co-maintainer. If you’re interested in improving OCaml tooling and think Spin is a good addition to OCamlers’ toolchain, please DM me 
