workshop-setup3.0.0 • Public • Published
Verify and setup a repository for workshop attendees
I make quite a few workshops and one of the biggest challenges I have is making sure that people have set things up correctly so the workshop has as few surprises as possible. So I want to have a script validate things on attendees machines before they start on the workshop and give them helpful info to fix problems early and on their own.
The problem is further complicated by the fact that I can't use any modules to do this because I can pretty much only guarantee that attendees have some version of node and npm, but not which version. So I need something that exists when they clone the repository right from the start.
This exposes a simple function that takes an array of validators which return
strings of helpful text (or a promise that resolves to a string of helpful text)
if the system is not valid (or
null if it is valid). To overcome the issue of
not being able to install things, there is a bundled version of this module that
you can download from the registry and commit directly to your project.
Table of Contents
- Other Solutions
The way I expect people to use this module is by downloading the UMD build and
committing it directly into their project. You can download the UMD build via
npm if you like (then just copy/paste the file from
node_modules) or download
unpkg.com here: https://unpkg.com/workshop-setup/dist/index.js
curl -o scripts/workshop-setup.js -L https://unpkg.com/workshop-setup/dist/index.js
npm install --save-dev workshop-setup
Here's what I recommend:
- Download the workshop-setup script into
enginesconfig to your
- Add a
- Create the
- And put this in it:
var path =var pkg =// if you install it then this should be require('workshop-setup')// but that... doesn't really make sense.
Whether you install it or download it, usage is basically the same. The difference is how you require it.
// if you install it, you'd dovar workshopSetup =// if you download it, you'd do something like:var workshopSetup =
This allows you to verify the user's system is correct:
var verifySystem = verifySystemvar verifyPromise =verifyPromise
You can also specify custom validators. There are several utilities exposed by
workshop-setup as well which can be quite helpful.
The built-in validators available on
Most of the utils are simply exposing other modules which are bundled with
workshop-setup. These are available on
execValidator(desiredVersionRange, commandToGetVersion, messageFn)-
oneLine: a tag that allows you to have multiple lines for a message and it'll put it all on one line
satisfiesmethod on this one)
This will install dependencies in the given directory/directories (defaults to
var path =var installDeps = installDepsvar main = pathvar api = pathvar client = path// you can also do:// which is effectively// or, to be more specific:
This project was inspired by all of the people who have ever struggled to set up one of my workshops before. Hopefully it's easier now!
I'm unaware of any other solutions for this problem. Feel free to link them here if you find any.
Thanks goes to these people (emoji key):
Kent C. Dodds
💻 📖 🚇 ⚠️
This project follows the all-contributors specification. Contributions of any kind welcome!