Skip to content

Testbench for consistent Node/node_modules versions for dev and prod

Notifications You must be signed in to change notification settings

jamwafflesci/node-consistency-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-consistency-poc

Testbench for automatically configuring a Node environment on clone/pull/update/whatever.

Spec here

Demo

This example has two branches as an example:

  • master, has a dependency on Express 4 (yarn list express shows 4.x)
  • express-3, has a dependency on Express 3

Doing git checkout <branch> should set the correct Express version automatically. You can see this with yarn list express.

What assumptions are we making about the environment?

  • It has nvm installed
  • It has Bash somewhere

Yarn

Yarn is used because it's faster than NPM, whilst also being compatible. There is a yarn.lock file that should be tracked in the repository that will ensure Node package and package dependency version consistency between developer machines, as well as Docker images and production boxes.

The check-node-env.sh script will install the latest Yarn globally if it's not already present.

Bootstrapping

The bootstrap script is ./install-git-hooks.sh. It is run as a postinstall script when yarn install is ran. Seeing as yarn install must be run for the project to be used anyway, it's practically guaranteed that install-git-hooks.sh is run before anything else.

Git hooks

The post-merge script runs on pull The post-checkout script when the user changes a branch

Adding a Git hook

  • It should be added into githooks/
  • It should have the correct name for the Git hook you're targeting. Grep through the Git hooks docs for the options.
  • It should be executable (chmod +x githooks/*)

Building a server

  • Install NVM curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
  • TODO: Other firewally-type scripts from the current deploy

About

Testbench for consistent Node/node_modules versions for dev and prod

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published