From f9bbd83396fdca5943d9ef8202aaaae33bf1a03a Mon Sep 17 00:00:00 2001 From: Teodorus Nathaniel Date: Wed, 24 Dec 2025 18:14:24 +0700 Subject: [PATCH 1/2] feat: install dependencies for cases where consumer using plugin --- .github/workflows/prettier.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index fc9ca3f..414afe4 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -37,5 +37,8 @@ jobs: - name: Install Prettier run: bun i -g prettier + - name: Install Dependencies + run: bun i + - name: Check formatting run: prettier --check . From 22b2dbb6ca0837ecfb18d5b24c737214c5e9f28a Mon Sep 17 00:00:00 2001 From: Teodorus Nathaniel Date: Wed, 24 Dec 2025 18:19:40 +0700 Subject: [PATCH 2/2] feat: install dependencies if the consumer have configs --- .github/workflows/commit-check.yml | 25 ++++++++++++++++++++----- .github/workflows/prettier.yml | 6 +++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index a3400d0..872d9b8 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -14,17 +14,32 @@ jobs: with: bun-version: latest - - name: Install commitlint + - name: Check for commitlint config and install dependencies + id: commitlint-config + run: | + if [ -f .commitlintrc.json ] || [ -f .commitlintrc.js ] || [ -f .commitlintrc.yml ] || [ -f .commitlintrc.yaml ] || grep -q '"commitlint"' "package.json" 2>/dev/null; then + echo "has-config=true" >> $GITHUB_OUTPUT + else + echo "has-config=false" >> $GITHUB_OUTPUT + fi + + - name: Install dependencies if config exists + if: steps.commitlint-config.outputs.has-config == 'true' + run: | + bun i -g @commitlint/cli + bun i + + - name: Install commitlint globally if no config + if: steps.commitlint-config.outputs.has-config == 'false' run: | bun i -g @commitlint/cli bun i -D @commitlint/config-conventional - name: Create commitlint config if missing + if: steps.commitlint-config.outputs.has-config == 'false' run: | - if [ ! -f .commitlintrc.json ] && [ ! -f .commitlintrc.js ] && [ ! -f .commitlintrc.yml ] && [ ! -f .commitlintrc.yaml ] && ! grep -q '"commitlint"' "package.json" 2>/dev/null; then - echo "extends:" > .commitlintrc.yml - echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml - fi + echo "extends:" > .commitlintrc.yml + echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml - name: Check PR title if: github.event_name == 'pull_request' diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 414afe4..051b5eb 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -10,6 +10,7 @@ jobs: - uses: actions/checkout@v4 - name: Check for Prettier config + id: prettier-config run: | CONFIG_FILES=".prettierrc .prettierrc.json .prettierrc.js .prettierrc.yaml .prettierrc.yml .prettierrc.toml prettier.config.js prettier.config.mjs" HAS_CONFIG=false @@ -21,7 +22,7 @@ jobs: fi done - if [ "$HAS_CONFIG" = false ] && ! grep -q '"prettier"' "package.json" 2>/dev/null; then + if [ "$HAS_CONFIG" = false ]; then echo "::error file=.prettierrc::No Prettier configuration file found." echo "A Prettier config file is required to ensure consistent formatting across all developers." echo "Without a shared config, each developer's local Prettier settings will differ, causing unnecessary formatting changes in commits." @@ -29,6 +30,8 @@ jobs: exit 1 fi + echo "has-config=true" >> $GITHUB_OUTPUT + - name: Setup Bun uses: oven-sh/setup-bun@v2 with: @@ -38,6 +41,7 @@ jobs: run: bun i -g prettier - name: Install Dependencies + if: steps.prettier-config.outputs.has-config == 'true' run: bun i - name: Check formatting