|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -o errexit |
| 4 | + |
| 5 | +if [ -d "./node_modules/.bin" ]; then |
| 6 | + export PATH="./node_modules/.bin:$PATH" |
| 7 | +fi |
| 8 | + |
| 9 | +function setup() { |
| 10 | + echo -e "🔄 updating asdf…\n" |
| 11 | + asdf update |
| 12 | + |
| 13 | + echo -e "" |
| 14 | + echo -e "🔄 updating asdf's plugins…\n" |
| 15 | + asdf plugin update nodejs |
| 16 | + |
| 17 | + echo -e "" |
| 18 | + echo -e "⬇️ installing asdf's packages…\n" |
| 19 | + asdf install |
| 20 | + |
| 21 | + echo -e "" |
| 22 | + echo -e "🔄 updating npm…\n" |
| 23 | + npm up npm --global |
| 24 | + |
| 25 | + echo -e "" |
| 26 | + echo -e "⬇️ installing packages with npm…\n" |
| 27 | + npm ci |
| 28 | +} |
| 29 | + |
| 30 | +function cleanup() { |
| 31 | + echo -e "🗑️ deleting './node_modules' folder…\n" |
| 32 | + rm -rf ./node_modules |
| 33 | + |
| 34 | + echo -e "" |
| 35 | + echo -e "🗑️ deleting './package-lock.json' file…\n" |
| 36 | + rm ./package-lock.json |
| 37 | + |
| 38 | + echo -e "" |
| 39 | + echo -e "⬇️ installing packages with npm…\n" |
| 40 | + npm install |
| 41 | +} |
| 42 | + |
| 43 | +function doc() { |
| 44 | + echo -e "🤖 generating documentation with Typedoc…\n" |
| 45 | + typedoc "./src/index.ts" |
| 46 | +} |
| 47 | + |
| 48 | +function test() { |
| 49 | + echo -e "🧪 executing unit tests with Jest…\n" |
| 50 | + jest |
| 51 | +} |
| 52 | + |
| 53 | +function lint() { |
| 54 | + echo -e "🕵 linting source code with ESLint…\n" |
| 55 | + eslint "*/**/*.{ts,js,json}" |
| 56 | +} |
| 57 | + |
| 58 | +function autofix() { |
| 59 | + echo -e "👨🔧 automatically fixing source code with ESLint…\n" |
| 60 | + eslint "*/**/*.{ts,js,json}" --fix |
| 61 | +} |
| 62 | + |
| 63 | +function bundle() { |
| 64 | + echo -e "📦 bundling source code with Rollup…\n" |
| 65 | + rollup --config ./rollup.config.mjs |
| 66 | +} |
| 67 | + |
| 68 | +function prepublish-only() { |
| 69 | + echo -e "▶ executing 'doc' command…\n" |
| 70 | + bash run doc |
| 71 | + |
| 72 | + echo "" |
| 73 | + echo -e "▶ executing 'lint' command…\n" |
| 74 | + bash run lint |
| 75 | + |
| 76 | + echo "" |
| 77 | + echo -e "▶ executing 'test' command…\n" |
| 78 | + bash run test |
| 79 | + |
| 80 | + echo "" |
| 81 | + echo -e "▶ executing 'bundle' command…\n" |
| 82 | + bash run bundle |
| 83 | +} |
| 84 | + |
| 85 | +eval "$@" |
0 commit comments