diff --git a/package.json b/package.json index 05024644b..d9bad9352 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ ] }, "scripts": { + "bootstrap": "./scripts/bootstrap.sh", + "update": "./scripts/install-modules.sh", "test": "jest", "test-watch": "jest --watch", "test-coverage": "jest --coverage", diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 100755 index 000000000..ba70a3cdd --- /dev/null +++ b/scripts/bootstrap.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +source scripts/remove-modules.sh +source scripts/install-modules.sh + +cd packages/kyt-cli && npm link && printf "\nšŸ‘ linked kyt-cli\n" + +printf "\nāœ… Strapped\n" diff --git a/scripts/get-packages.sh b/scripts/get-packages.sh new file mode 100644 index 000000000..f0f54598f --- /dev/null +++ b/scripts/get-packages.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +PACKAGES=( "" ) +ROOT=`pwd` + +for DIR in packages/*; do + [[ -d $DIR ]] && PACKAGES+=("$DIR") +done diff --git a/scripts/install-modules.sh b/scripts/install-modules.sh new file mode 100755 index 000000000..0bfc61854 --- /dev/null +++ b/scripts/install-modules.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +source scripts/get-packages.sh + +printf "\nšŸ”„ Installing packages\n" + +# Installs node modules for packages/*. +for i in "${PACKAGES[@]}"; do : + cd "${ROOT}/${i}" + echo "šŸ‘ Installing package ${ROOT}/${i}/package.json" + npm i 2>&1 + cd "${ROOT}" +done + +printf "\nāœ… Done installing packages\n" diff --git a/scripts/remove-modules.sh b/scripts/remove-modules.sh new file mode 100755 index 000000000..ea996fdc7 --- /dev/null +++ b/scripts/remove-modules.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +source scripts/get-packages.sh + +printf "\nšŸ”„ Removing node modules\n" + +# Removes packages/*/node_modules directories. +# Runs all commands in parallel/background. +for i in "${PACKAGES[@]}"; do + NMODS="${ROOT}/${i}/node_modules" + if [ -d "${NMODS}" ]; then + echo "šŸ‘ Removing ${NMODS}" + rm -rf "${NMODS}" 2>&1 & + fi +done + +wait + +printf "\nāœ… Done removing node modules\n"