Skip to content

Developer setup

Nathanaël edited this page Jan 18, 2021 · 40 revisions

Requirements

  • NodeJS (at least v14)
  • MySQL or MariaDB

Scripts needed

  • .git/hooks/pre-commit
#!/bin/sh

if [ "$(git diff --name-only HEAD@{1} HEAD | grep "^server/")" != "" ]; then
    cd "$(git rev-parse --show-toplevel)/server" || exit 1
    npm run format || exit 1
    npm run lint || exit 1
    npm run test || exit 1
fi

if [ "$(git diff --name-only HEAD@{1} HEAD | grep "^client/")" != "" ]; then
    cd "$(git rev-parse --show-toplevel)/client" || exit 1
    npm run format || exit 1
    npm run lint || exit 1
    npm run test -- --watchAll=false || exit 1
fi

exit 0
  • .git/hooks/post-merge if you forget to npm i after a pull
#!/bin/sh

function changed() {
  git diff --name-only HEAD@{1} HEAD | grep "^$1" >/dev/null 2>&1
}

cd "$(git rev-parse --show-toplevel)/server" || exit 1
if changed 'server/package-lock.json'; then
  echo "📦 server/package-lock.json changed. Running npm install"
  npm install || exit 1
fi

cd "$(git rev-parse --show-toplevel)/client" || exit 1
if changed 'client/package-lock.json'; then
  echo "📦 client/package-lock.json changed. Running npm install"
  npm install || exit 1
fi

exit 0

Create the database

[mysql]: CREATE USER 'glowing-octo-guacamole'@'localhost' IDENTIFIED BY 'p@ssword';
[mysql]: CREATE DATABASE glowingOctoGuacamoleDev;
[mysql]: GRANT ALL PRIVILEGES ON glowingOctoGuacamoleDev.* TO 'glowing-octo-guacamole'@'localhost';

Run development server

You can use nodemon to auto-reload the servers on changes. You can launch two instances, one for client/ and the other for server/

Clone this wiki locally