[ANN] Spin 0.8.0

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 hello command to generate a tutorial project

  • Added a parse_binaries stanza that can be true to force Spin to parse binary files

  • Added a raw_files stanza that takes a list of file or glob expressions to instruct Spin to copy files instead of parsing them

  • Added a new c-bindings template for C bindings using ctypes

  • Added a new js template for javascript applications with js_of_ocaml

Changed

  • Removed the gen subcommand. 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 ISC license

  • Increase version of ocamlformat to 0.18.0 in 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 StdLabels in templates

  • The spa template 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 test stanza for unit tests now that Alcotest prints colors by default

  • Remove unused flags defined in the root’s dune file

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 variable SPIN_CREATE_SWITCH=false

  • Fix an CLI incompatibility between opam.2.0.X and opam.2.1.X that 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 :slight_smile:

15 Likes

I spun up a template for the first time, the dream template to be exact. This is pretty straightforward.

Do you think there should be a readme section pointing to quickly get the users started and running whatever the template is supposed to run? I was wondering how to best run the app. It took me a bit to notice the Makefile. I was wondering, oh should I use dune or esy? No esy. Okay, so dune. Oh but there’s a Makefile!

1 Like

The official templates come with a CONTRIBUTING.md guide that documents how to set up your development environment and run the binary if the project contains one.

I can certainly add one to the dream template :slight_smile:

The templates also end with a list of example commands to run at the root of the project. The dream template, for instance, finishes with:

image

Which gives a gist of what the workflow of the project is.