Keeping developer environments up to date and in sync with each other can be a challenging thing as a web site's environment is so much more than just code that can be pulled down. I've seen a common scenario play out that I wanted to help solve with a utility that I had been mentally concocting for awhile and am now releasing, preflight-check. Before I share what the tool does, let me share the pain of the common scenario I've often seen.

  • Developer A adds a new dependency to package.json, composer.json, bower.json or any other file that describes other files to pull down that do not exist in the git repo. They then write code that depends on those dependencies and makes a Pull Request to merge it all into develop.
  • Developer B pulls down develop after the aforementioned Pull Request has been merged in and begins work without running the necessary commands to install dependencies (aka npm install etc). Their site doesn't work or gives an error as the code written and committed does not have the required library, module, or dependency to correctly work.
  • After spending too much time troubleshooting the issue, Developer B finally runs the commands to get things working again. Maybe they realized that package.json changed in the last git pull and should run npm install, maybe they pinged their project chat room and Developer A chimed in with the solution, or maybe they just reinstalled everything. This wastes too much time.

So I thought to myself: why can't the repo contain a list of files that if they changed, then a specific command would be run? The tool I've made, preflight-check, does just that in a flexible way. Here's a look at the config that it can take; notice how it's not just limited to installing dependencies, but can also compile CSS if Sass files have changed.

{
  "sets": [
    {
      "file": "package.json",
      "cmd": "npm install",
      "title": "Node dependencies"
    }, {
      "file": "path/to/theme/bower.json",
      "cmd": [
        "cd path/to/theme/",
        "bower install"
      ],
      "title": "Front end libraries"
    }, {
      "file": "path/to/theme/scss/**/*.scss",
      "cmd": "gulp css",
      "title": "Sass Compiling"
    }
  ]
}

The idea is that is ran before starting your project up, ideally by a prestart script that kicks off before npm start, or via a git hook after a pull. If you're interested in getting this set up, just take a look at the preflight-check repo to get started – it should only take 5 - 10 minutes to get this going on your project. I hope this helps you out on your project!! Please let me know if you have any issues or wild successes with this; thanks!