Universal dev/build scripts
I think we should agree on a universal standard for dev scripts for building and running a project.
Currently we have language-specific runners like npm
and lein
, which have language-specific functionality and options. We also have more general-purpose runners like make
and just
, which can theoretically be used for any language, but these have their own trade-offs (just
must be installed, and I’ve heard make
has some idiosyncrasies).
What would be great is if I could just clone any project, cd
into it, and run:
./scripts/dev
This would install all dependencies, including compilers and runtimes; build the project; and start it—in watch mode, where applicable. You would never have to read the readme or go down a dependency tree.
The main advantage of this is its simplicity, and the fact that the script itself would just be a shell script, making it available on any system without any extra steps. Project maintainers don’t have to do anything special to support the convention, and users don’t have to do anything special to take advantage of it.
Dependency installation would be interactive, so you could see what the script was doing and do things an alternate way if you preferred:
$ ./scripts/dev
No Rust compiler installed, install one before continuing:
[x] Quit
[ ] sudo apt install rustc
[ ] curl https://rust.org/install.sh | sh
We could have a repo somewhere of templates for these scripts. These would include a basic framework for interactivity and various ways of installing dependencies (prompting the user when something needs to be installed; installing docker, compilers, etc), as well as language-specific templates.
In simple cases, the dev
script would just call npm run dev
or whatever the language required. In these cases there would still be a lot of value in it, because to anyone not familiar at all with the Node ecosystem—who might already be deep into a tree of trying to figure out where some bug is coming from in a project that they didn’t even realise depended on Node—any friction to just starting the project will be a significant source of extra stress.
Besides simplicity and being available everywhere, I think interactivity and discoverability are important elements of a dev/build script solution. I shouldn’t have to read the docs or even the readme on a software project to make it build itself and run. ./scripts/dev
should always be there and it should always do something useful.
For example, in a monorepo where it doesn’t make sense to “run the whole project”:
$ ./scripts/dev
This is a monorepo, cd to a package to run it:
[x] Quit
[ ] cd packages/api-server; ./scripts/dev
[ ] cd packages/something-else; ./scripts/dev
Or if there are options required, a standard help text would be displayed.