diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b45e544..7103da86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,9 +52,7 @@ jobs: ${{ runner.os }}-bun- - name: Ensure dependencies - run: | - [ -d node_modules ] || bun install --frozen-lockfile - [ -d ui/node_modules ] || (cd ui && bun install --frozen-lockfile) + run: bash scripts/ensure-deps.sh - name: Run ${{ matrix.check.name }} run: ${{ matrix.check.cmd }} @@ -88,9 +86,7 @@ jobs: ${{ runner.os }}-bun- - name: Ensure dependencies - run: | - [ -d node_modules ] || bun install --frozen-lockfile - [ -d ui/node_modules ] || (cd ui && bun install --frozen-lockfile) + run: bash scripts/ensure-deps.sh - name: Build run: bun run build:all @@ -133,9 +129,7 @@ jobs: ${{ runner.os }}-bun- - name: Ensure dependencies - run: | - [ -d node_modules ] || bun install --frozen-lockfile - [ -d ui/node_modules ] || (cd ui && bun install --frozen-lockfile) + run: bash scripts/ensure-deps.sh - name: Download dist artifact uses: actions/download-artifact@v4 diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index e048677e..cf9f59d7 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -41,9 +41,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Install dependencies - run: | - bun install --frozen-lockfile - cd ui && bun install --frozen-lockfile + run: bash scripts/ensure-deps.sh - name: Build run: bun run build:all diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b0e2220..adb7a3e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,9 +37,7 @@ jobs: bun-version: '1.3.9' - name: Install dependencies - run: | - bun install --frozen-lockfile - cd ui && bun install --frozen-lockfile + run: bash scripts/ensure-deps.sh - name: Build package run: bun run build:all diff --git a/scripts/ensure-deps.sh b/scripts/ensure-deps.sh new file mode 100644 index 00000000..77a0914e --- /dev/null +++ b/scripts/ensure-deps.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +UI_DIR="$ROOT_DIR/ui" +UI_SENTINEL="$UI_DIR/node_modules/@date-fns/tz/date/mini.js" + +ensure_root_deps() { + if [[ ! -d "$ROOT_DIR/node_modules" ]]; then + echo "[deps] Installing root dependencies" + (cd "$ROOT_DIR" && bun install --frozen-lockfile) + fi +} + +ensure_ui_deps() { + if [[ -d "$UI_DIR/node_modules" && -f "$UI_SENTINEL" ]]; then + return + fi + + echo "[deps] Reinstalling UI dependencies" + rm -rf "$UI_DIR/node_modules" + (cd "$UI_DIR" && bun install --frozen-lockfile) +} + +ensure_root_deps +ensure_ui_deps