Skip to content

Conversation

@ujinsim
Copy link
Collaborator

@ujinsim ujinsim commented Oct 25, 2025

🔥 연관 이슈

🚀 작업 내용

  1. 버전 자동 증가 (ui 하위 새 폴더 추가됐을 경우 Major 버전,feat 커밋일 경우 Minor 버전, 그 외는 Patch 버전).

  2. src/shared/ui/ComponentName/ComponentName.tsx와 같은 패턴을 가진 새로운 컴포넌트의 내보내기 구문을 src/shared/index.ts에 자동으로 추가합니다.
    ( 다만 Typography처럼 하나의 파일에서 여러 개의 식별자를 내보내는 경우는 처리가 불가합니다 )

  3. 빌드 및 커밋/푸시를 수행합니다.

  4. 새 버전을 npm에 게시합니다.

💬 리뷰 중점사항

Summary by CodeRabbit

릴리스 노트

  • Chores
    • main으로 병합된 PR에서 자동으로 버전을 증가시키는 워크플로우 추가(기본 패치, PR 제목이 "feat"이면 마이너, 새 UI 추가 시 메이저 기준).
    • 새 UI 컴포넌트가 감지되면 공개 익스포트 목록을 자동으로 동기화.
    • 변경 사항이 감지되면 자동으로 빌드·커밋·퍼블리시를 수행하고, 변경 없으면 퍼블리시를 건너뜀.

@ujinsim ujinsim self-assigned this Oct 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 25, 2025

Walkthrough

main 브랜치로의 PR 병합을 감지해 자동으로 버전 증분(패치/마이너/메이저 판단), src/shared/ui의 컴포넌트 export 동기화(src/shared/index.ts), 빌드 및 npm 퍼블리시를 수행하는 GitHub Actions 워크플로우를 추가합니다. (package.json 변경 여부와 새 UI 폴더 유무로 버전 전략 결정)

Changes

Cohort / File(s) Change Summary
GitHub Actions 워크플로우
\.github/workflows/auto-bump-version.yaml
main 병합 트리거 워크플로우 추가: 체크아웃, Node.js v20 설정, PR의 package.json 변경 여부 검사 및 새 src/shared/ui 폴더 검사; package.json 미변경 시 새 UI 폴더→major, PR 제목이 feat로 시작→minor, 그 외→patch로 버전 bump; src/shared/ui.ts/.tsx 파일을 스캔해 src/shared/index.ts의 export 라인 생성/병합(기존 export 보존); 변경 시 package.jsonsrc/shared/index.ts 커밋·푸시(skip-ci); 의존성 설치·빌드 후 npm 퍼블리시(NPM_TOKEN 사용).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant GH as GitHub (PR merge)
    participant GA as GitHub Actions
    participant Repo as Repository
    participant Ver as Version Detector
    participant Scan as UI Export Scanner
    participant CI as CI Build / Publish

    GH->>GA: PR merged into main
    GA->>Repo: checkout main
    GA->>Ver: detect package.json change & new src/shared/ui folders
    alt package.json unchanged
        Ver->>Ver: decide bump (major if new UI folder, minor if title starts "feat", else patch)
        Ver->>Repo: update package.json
    else package.json changed
        Ver->>GA: keep PR's package.json version
    end
    GA->>Scan: scan `src/shared/ui` for .ts/.tsx components
    Scan->>Scan: generate export lines and merge into `src/shared/index.ts`
    alt changes detected
        Scan->>Repo: stage & commit `package.json` + `src/shared/index.ts` (skip-ci)
        Repo->>CI: install deps & build
        CI->>CI: npm publish (using NPM_TOKEN)
    else no changes
        Scan->>GA: log "no changes" and skip publish
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • 버전 결정 로직(새 UI 폴더 → major, 제목 기반 minor) 검증 필요
  • src/shared/index.ts 병합 로직(정규식/파일 파싱, 기존 export 보존) 검토 필요
  • 커밋·푸시 권한, skip-ci 토큰/credential 사용과 npm 퍼블리시 조건 확인 필요

Possibly related PRs

Suggested reviewers

  • keemsebin
  • yougyung

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 main 브랜치 머지 시 npm 자동 배포 및 버저닝 설정에 대해 명확하게 설명하고 있으며, 변경사항의 주요 목적을 잘 요약하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 모든 필수 섹션(연관 이슈, 작업 내용, 리뷰 중점사항)을 포함하고 있으며, 구현 내용을 상세하게 기술하고 있습니다.
Linked Issues check ✅ Passed GitHub Actions 워크플로우가 main 브랜치 머지 시 자동 npm 배포[#84]와 변경사항 감지 후 자동 버전 업데이트[#84]의 모든 요구사항을 충족하고 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 GitHub Actions 워크플로우 파일에 국한되어 있으며, 연관 이슈 #84에서 요구하는 자동 배포 및 버저닝 구현과 직접 관련이 있습니다.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#84

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the chore label Oct 25, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 014d0a2 and 5cccbd8.

📒 Files selected for processing (1)
  • .github/workflows/auto-bump-version.yaml (1 hunks)

@ujinsim ujinsim marked this pull request as draft October 25, 2025 13:06
@ujinsim ujinsim marked this pull request as ready for review October 28, 2025 11:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (5)
.github/workflows/auto-bump-version.yaml (5)

28-41: package.json 버전 변경 감지 정규식이 부정확함 - 값 변경 여부 확인 필요

정규식 패턴 /"version"\s*:/"version" 키의 존재만 확인하고, 실제 값 변경은 감지하지 않습니다. 포맷 변경만 있어도 감지될 수 있습니다.

patch에서 실제 버전 값을 비교하도록 개선하세요:

const files = await github.paginate(github.rest.pulls.listFiles, {
  owner: context.repo.owner,
  repo: context.repo.repo,
  pull_number: pr,
  per_page: 100
});

let changed = false;
for (const f of files) {
  if (f.filename === 'package.json' && f.patch) {
    const oldMatch = f.patch.match(/^-\s*"version"\s*:\s*"([^"]+)"/m);
    const newMatch = f.patch.match(/^\+\s*"version"\s*:\s*"([^"]+)"/m);
    if (oldMatch && newMatch && oldMatch[1] !== newMatch[1]) {
      changed = true;
      break;
    }
  }
}
core.setOutput('changed', changed ? 'true' : 'false');

86-86: export 정규식이 제한적 - 쌍따옴표 미지원

Line 86의 정규식이 작은따옴표(')만 지원하고, 큰따옴표(")는 지원하지 않습니다. TypeScript에서는 두 가지 모두 사용되므로 누락될 수 있습니다.

정규식을 개선하세요:

for (const m of content.matchAll(/export\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g)) {

89-90: export 경로 구성 로직 - 복잡성 및 유지보수성 개선

Line 90의 경로 구성 로직이 과도하게 중첩되어 있어 가독성이 낮고 버그 위험이 있습니다.

로직을 단순화하세요:

const base = f.replace(/\/index\.d\.ts$/, '');
const relativePath = base.substring(root.length).replace(/^\//, '');
const importPath = relativePath ? './' + relativePath : '.';
const line = `export { ${names} } from '${importPath}/${fromRel}';`;
if (!indexContent.includes(line)) {
  adds.push(line);
}

89-91: export 중복 검사 - 부분 문자열 매칭으로 인한 오탐

Line 91의 indexContent.includes(names) 검사는 부분 문자열 매칭을 수행하므로 오탐이 발생할 수 있습니다. 예를 들어 기존 Button export가 있으면 PrimaryButton은 추가되지 않습니다.

전체 export 라인으로 비교하도록 개선하세요:

const line = `export { ${names} } from '${importPath}/${fromRel}';`;
if (!indexContent.includes(line)) {
  adds.push(line);
}

103-113: npm publish 단계 누락 - PR 목표 미이행

PR 목표에서 명시한 "main 브랜치에 머지될 때 npm 자동 배포"가 구현되지 않았습니다. 현재 워크플로우는 버전 업데이트와 export 동기화만 수행하고, 실제 npm에 배포하는 단계가 없습니다.

Commit & Push 단계 후에 npm publish 단계를 추가하세요:

      - name: Commit & Push
        run: |
          if git diff --quiet; then
            echo "No changes to commit."
            exit 0
          fi
          git config user.name  "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add package.json dist/shared/index.d.ts || true
          git commit -m "chore: bump version and sync UI exports [skip ci]"
          git push

      - name: Publish to npm
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

참고: GitHub 저장소 settings에 NPM_TOKEN secret이 설정되어 있어야 합니다.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cccbd8 and 0b6ff7d.

📒 Files selected for processing (1)
  • .github/workflows/auto-bump-version.yaml (1 hunks)

@ujinsim ujinsim marked this pull request as draft October 28, 2025 11:21
@ujinsim ujinsim marked this pull request as ready for review October 29, 2025 04:48
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
.github/workflows/auto-bump-version.yaml (1)

44-63: Line 49: context 객체는 순수 run 단계에서 접근 불가 - ReferenceError 발생

node -e 인라인 스크립트에서는 context 객체가 존재하지 않습니다. contextgithub-script 액션 내에서만 사용 가능하며, 일반 run: 단계에서는 접근할 수 없습니다. 이 코드는 실행 시 ReferenceError: context is not defined 오류를 발생시킵니다.

추가로 54-58줄에 들여쓰기 일관성이 없습니다 (2/4 스페이스 혼용).

환경 변수를 통해 PR 제목을 전달하도록 수정하세요:

      - name: Bump patch version (+0.0.1) if not changed in PR
        if: steps.ver_changed.outputs.changed != 'true'
+       env:
+         PR_TITLE: ${{ github.event.pull_request.title }}
        run: |
          node -e "
            const fs = require('fs');
-           const pr_title = context.payload.pull_request.title;
+           const pr_title = process.env.PR_TITLE;
            const pkg = JSON.parse(fs.readFileSync('package.json','utf8'));
            const [a,b,c] = pkg.version.split('.').map(Number);
            let new_version;

            if (pr_title.toLowerCase().startsWith('feat')) {
-               new_version = [a,b+1,0].join('.');
+              new_version = [a,b+1,0].join('.');
            } else {
              new_version = [a,b,c+1].join('.');
            }

            pkg.version = new_version;
            fs.writeFileSync('package.json', JSON.stringify(pkg,null,2)+'\n');
            console.log('Bumped to', pkg.version);
          "
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b6ff7d and 56cf88f.

📒 Files selected for processing (1)
  • .github/workflows/auto-bump-version.yaml (1 hunks)

Comment on lines 76 to 77
const existingExports = new Set((indexContent.match(/from\\s+['\\\"](\\.\\/|\\.\\.\\/)([^'\\\"]+)['\\\"]/g) || [])
.map(line => line.match(/from\\s+['\\\"]([^'\\\"]+)['\\\"]/)[1]));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Lines 76-77: 정규식 패턴 개선 - 다양한 export 형식 지원

현재 정규식이 기존 export를 추출할 때 모든 형식을 완벽히 지원하지 않을 수 있습니다. 큰따옴표와 작은따옴표 모두, 다양한 whitespace 패턴을 수용하도록 개선하세요:

-            const existingExports = new Set((indexContent.match(/from\\s+['\\\"](\\.\\/|\\.\\.\\/)([^'\\\"]+)['\\\"]/g) || [])
-                                  .map(line => line.match(/from\\s+['\\\"]([^'\\\"]+)['\\\"]/)[1]));
+            const existingExports = new Set((indexContent.match(/from\s+['"]([^'"]+)['"]/g) || [])
+                                  .map(line => {
+                                    const match = line.match(/from\s+['"]([^'"]+)['"]/);
+                                    return match ? match[1] : null;
+                                  }).filter(Boolean));

이렇게 수정하면 작은따옴표/큰따옴표 혼용, 다양한 whitespace를 지원하며, 매칭 실패 시 안전하게 처리합니다.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In .github/workflows/auto-bump-version.yaml around lines 76-77, the current
regex used to collect existing exports is brittle and may fail on different
quote styles, whitespace variations, or when match returns null; update the
pattern to accept both single and double quotes, allow optional whitespace
around tokens and relative path prefixes, and change the mapping to safely guard
against null matches (skip non-matches) before accessing capture groups so you
don't attempt to index undefined matches.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (2)
.github/workflows/auto-bump-version.yaml (2)

44-63: Line 49: PR 제목에 접근할 수 없음 - ReferenceError 발생

node -e 인라인 스크립트 내에서 context.payload.pull_request.title을 참조하고 있으나, context 객체는 해당 스크립트 컨텍스트에서 사용 불가합니다. 실행 시 ReferenceError: context is not defined 오류가 발생합니다.

PR 제목을 환경 변수를 통해 전달하도록 수정하세요:

      - name: Bump patch version (+0.0.1) if not changed in PR
        if: steps.ver_changed.outputs.changed != 'true'
+       env:
+         PR_TITLE: ${{ github.event.pull_request.title }}
        run: |
          node -e "
            const fs = require('fs');
-           const pr_title = context.payload.pull_request.title;
+           const pr_title = process.env.PR_TITLE;
            const pkg = JSON.parse(fs.readFileSync('package.json','utf8'));

또한 Line 55-56의 들여쓰기 불일치를 수정하세요 (2/4 스페이스 혼용).


76-77: Lines 76-77: 정규식 매칭 후 안전성 검증 누락 - TypeError 위험

.map() 콜백에서 정규식 match() 결과에 바로 [1]로 접근하고 있으나, 매칭 실패 시 null이 반환되므로 TypeError가 발생합니다. 또한 현재 정규식은 다양한 인용 부호 및 whitespace 변동을 완벽히 수용하지 않습니다.

다음과 같이 개선하세요:

-            const existingExports = new Set((indexContent.match(/from\\s+['\\\"](\\.\\/|\\.\\.\\/)([^'\\\"]+)['\\\"]/g) || [])
-                                  .map(line => line.match(/from\\s+['\\\"]([^'\\\"]+)['\\\"]/)[1]));
+            const existingExports = new Set((indexContent.match(/from\s+['"]([^'"]+)['"]/g) || [])
+                                  .map(line => {
+                                    const match = line.match(/from\s+['"]([^'"]+)['"]/);
+                                    return match ? match[1] : null;
+                                  }).filter(Boolean));
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56cf88f and cc75c0a.

📒 Files selected for processing (1)
  • .github/workflows/auto-bump-version.yaml (1 hunks)

Comment on lines +29 to +42
- name: Detect if package.json version changed in PR
id: ver_changed
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request.number;
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr,
per_page: 100
});
const touched = files.some(f => f.filename === 'package.json' && /"version"\s*:/.test(f.patch || ''));
core.setOutput('changed', touched ? 'true' : 'false');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Line 41: 버전 변경 감지 로직 개선 - 정확성 고려

현재 정규식 패턴 /"version"\s*:/.test(f.patch || '')"version" 키의 존재 여부만 확인하며, 실제 버전 이 변경되었는지는 검증하지 않습니다. JSON 포매팅 변경이나 다른 필드 수정으로도 거짓 양성(false positive)이 발생할 수 있습니다.

patch 컨텐츠에서 이전 버전과 새 버전의 실제 semver 문자열을 추출하여 비교하면 더 정확합니다:

const versionMatch = (f.patch || '').match(/^-.*"version"\s*:\s*"([^"]+)"[\s,]/m);
const newVersionMatch = (f.patch || '').match(/^\+.*"version"\s*:\s*"([^"]+)"[\s,]/m);
const touched = versionMatch && newVersionMatch && versionMatch[1] !== newVersionMatch[1];
🤖 Prompt for AI Agents
In .github/workflows/auto-bump-version.yaml around lines 29 to 42, the current
regex only detects the "version" key and can yield false positives; instead
parse the patch to extract the old and new version values and compare them.
Update the script to search the patch for a line removed (starts with '-')
containing "version": "oldVersion" and a line added (starts with '+') containing
"version": "newVersion", ensure both matches are found and non-null, compare
oldVersion !== newVersion, and set the 'changed' output to 'true' only if they
differ; include safe null checks to avoid runtime errors.

Comment on lines 103 to 105
const line = \`export { \${componentName} } from '\${exportPath}'\`;
adds.push(line);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Line 103: export 라인 템플릿에 세미콜론 누락

export 문 끝에 세미콜론이 없습니다:

const line = \`export { \${componentName} } from '\${exportPath}'\`;
//                                                              ↑ 세미콜론 필요

Line 109에서 adds.join(';\\n')으로 결합하므로, 각 라인 끝에 세미콜론이 있어야 합니다:

-               const line = \`export { \${componentName} } from '\${exportPath}'\`;
+               const line = \`export { \${componentName} } from '\${exportPath}';\`;
🤖 Prompt for AI Agents
.github/workflows/auto-bump-version.yaml around lines 103-105: the export line
template currently misses a trailing semicolon which is required because later
code joins entries with ';\\n'; update the template to include a semicolon at
the end of the string (i.e., ensure the exported line ends with ';') so the
final joined output has correctly terminated export statements.

Comment on lines +132 to +135
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Lines 132-135: npm publish 조건 검토 - 변경사항 없을 때 동작

npm publish 단계가 이전 "Commit & Push" 단계의 조건부 로직과 독립적으로 항상 실행됩니다. 변경사항이 없어서 Commit & Push에서 exit 0으로 조용히 종료되어도, npm publish는 시도되어 이미 배포된 버전 재배포 오류를 유발할 수 있습니다.

변경사항이 있을 때만 publish하도록 보호하세요. 예를 들어, Commit & Push에서 성공 여부를 변수로 저장 후 publish 단계에서 조건 확인:

      - name: Commit & Push
        id: commit_push
        run: |
          if git diff --quiet; then
            echo "changed=false" >> $GITHUB_OUTPUT
            exit 0
          fi
          git config user.name  "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add package.json src/shared/index.ts || true
          git commit -m "chore: bump version and sync shared exports [skip ci]"
          git push
          echo "changed=true" >> $GITHUB_OUTPUT

      - name: Publish to npm
        if: steps.commit_push.outputs.changed == 'true'
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
🤖 Prompt for AI Agents
.github/workflows/auto-bump-version.yaml around lines 132-135: the "Publish to
npm" step always runs even when the prior "Commit & Push" step did nothing,
which can cause re-publish errors; modify the workflow so the "Commit & Push"
step sets an output flag (e.g., id: commit_push and echo "changed=true" or
"changed=false" to GITHUB_OUTPUT based on git diff) and then add a conditional
to the "Publish to npm" step (if: steps.commit_push.outputs.changed == 'true')
so npm publish only runs when changes were pushed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
.github/workflows/auto-bump-version.yaml (1)

153-163: npm publish 단계가 항상 실행되어 이미 배포된 버전 재배포 오류 야기 가능

"Commit & Push" 단계는 변경사항이 없으면 exit 0으로 종료되지만, "Publish to npm" 단계(Line 165-168)는 항상 실행되어 이미 배포된 버전을 재배포하려고 시도할 수 있습니다.

변경사항이 있을 때만 publish하도록 보호하세요. "Commit & Push" 단계에 id를 추가하고 출력 플래그를 설정한 후, npm publish 단계에서 조건을 확인하세요:

       - name: Commit & Push
+        id: commit_push
         run: |
           if git diff --quiet; then
             echo "No changes to commit."
+            echo "changed=false" >> $GITHUB_OUTPUT
             exit 0
           fi
           git config user.name  "github-actions[bot]"
           git config user.email "github-actions[bot]@users.noreply.github.com"
           git add package.json src/shared/index.ts || true
           git commit -m "chore: bump version and sync shared exports [skip ci]"
           git push
+          echo "changed=true" >> $GITHUB_OUTPUT

       - name: Publish to npm
+        if: steps.commit_push.outputs.changed == 'true'
         run: npm publish
         env:
           NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6491be5 and a3e0c91.

📒 Files selected for processing (1)
  • .github/workflows/auto-bump-version.yaml (1 hunks)
🔇 Additional comments (1)
.github/workflows/auto-bump-version.yaml (1)

82-91: PR 목표와 코드 동작의 불일치 확인 필요

코드 검증 결과:

  • .github/workflows/auto-bump-version.yaml 라인 53-69: src/shared/ui/ 경로에 새 파일이 추가되면 is_new_ui=true로 설정
  • 라인 82-84: is_new_ui=true일 때 메이저 버전을 자동으로 증가 [a + 1, 0, 0]

리뷰 의견의 모순 주장을 검증하려면 실제 PR 설명에서 명시된 버전 관리 정책을 확인해야 합니다. 현재 환경에서 PR 메타데이터에 접근할 수 없어 다음을 수동으로 확인하세요:

  1. PR 설명에 "메이저 버전은 자동 처리하지 않고 수동으로만 관리"라는 내용이 있는지
  2. 있다면, 새 UI 폴더 추가 시 메이저 버전 자동 증가가 의도된 동작인지 확인
  3. 의도되지 않은 경우, 리뷰 의견의 제시된 diff를 적용하여 is_new_ui 조건 제거 필요

pull_number: pr,
per_page: 100
});
const touched = files.some(f => f.filename === 'package.json' && /"version"\s*:/.test(f.patch || ''));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

버전 변경 감지 로직이 키 존재 여부만 확인 - 실제 값 변경 미감지

현재 정규식 /"version"\s*:/.test(f.patch || '')"version" 키가 있는지만 확인하고, 실제로 버전 이 변경되었는지는 검증하지 않습니다. JSON 포매팅 변경이나 다른 필드 수정으로도 거짓 양성이 발생할 수 있습니다.

patch 컨텐츠에서 이전/새 버전값을 직접 추출하여 비교하도록 개선하세요:

const versionMatch = (f.patch || '').match(/^-.*"version"\s*:\s*"([^"]+)"/m);
const newVersionMatch = (f.patch || '').match(/^\+.*"version"\s*:\s*"([^"]+)"/m);
const touched = versionMatch && newVersionMatch && versionMatch[1] !== newVersionMatch[1];

🏁 Script executed:

#!/bin/bash
# Examine the workflow file to verify the version detection logic
cat .github/workflows/auto-bump-version.yaml | head -60

Length of output: 1827


🏁 Script executed:

#!/bin/bash
# Search for context around the version detection logic
rg -n "touched.*files.some" -A 5 -B 5 .github/workflows/auto-bump-version.yaml

Length of output: 479


🏁 Script executed:

#!/bin/bash
# Look for any other version detection or comparison logic in the workflow
rg -n "version" -i .github/workflows/auto-bump-version.yaml | head -20

Length of output: 769


라인 42의 버전 변경 감지 로직이 키 존재 여부만 확인 - 실제 값 변경 미감지

현재 정규식 /"version"\s*:/.test(f.patch || '')"version" 키가 diff의 어디든 나타나면 참을 반환합니다. GitHub API의 patch 형식은 변경사항(-, +)뿐만 아니라 컨텍스트 라인(변경 없는 라인)도 포함하므로, 버전 필드가 diff 컨텍스트에 나타나기만 해도 거짓 양성이 발생합니다.

실제 버전 값 변경을 감지하도록 개선하세요:

const versionMatch = (f.patch || '').match(/^-.*"version"\s*:\s*"([^"]+)"/m);
const newVersionMatch = (f.patch || '').match(/^\+.*"version"\s*:\s*"([^"]+)"/m);
const touched = versionMatch && newVersionMatch && versionMatch[1] !== newVersionMatch[1];
🤖 Prompt for AI Agents
.github/workflows/auto-bump-version.yaml lines 42: the current check only tests
for the presence of a "version" key in the patch and can produce false positives
because GitHub patch includes context lines; update the logic to extract the old
and new version strings from lines that start with '-' and '+' respectively
(using regex anchored to those prefixes), then set touched to true only when
both matches exist and the extracted versions differ, and ensure you safely
handle empty or undefined f.patch before matching.

Comment on lines +112 to +139
const existingExports = new Set(
(indexContent.match(/from\\s+['\\\"](\\.\\/|\\.\\.\\/)([^'\\\"]+)['\\\"]/g) || [])
.map(line => line.match(/from\\s+['\\\"]([^'\\\"]+)['\\\"]/)[1])
);
const adds = [];
const uiRoot = path.join(root, 'ui');
const componentFiles = [];
if (fs.existsSync(uiRoot)) {
fs.readdirSync(uiRoot, { withFileTypes: true })
.filter(d => d.isDirectory())
.forEach(dir => {
const dirPath = path.join(uiRoot, dir.name);
const innerItems = fs.readdirSync(dirPath, { withFileTypes: true });
for (const item of innerItems) {
if (item.isFile() && (item.name.endsWith('.ts') || item.name.endsWith('.tsx')) && item.name !== 'index.ts') {
componentFiles.push(path.join(dir.name, item.name));
}
}
});
}

for (const relativeFilePath of componentFiles) {
const componentName = path.basename(relativeFilePath, path.extname(relativeFilePath));
const exportPath = './ui/' + relativeFilePath.replace(path.extname(relativeFilePath), '');
if (existingExports.has(exportPath)) continue;
const line = \`export { \${componentName} } from '\${exportPath}'\`;
adds.push(line);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

export 감지 정규식 패턴이 제한적 - 오류 위험 존재

Lines 113-115의 정규식이 특정 형식만 감지하며, 예상치 못한 형식에서 .match()[1] 접근 시 오류가 발생할 수 있습니다:

(indexContent.match(/from\\s+['\\\"](\\.\\/|\\.\\.\\/)([^'\\\"]+)['\\\"]/g) || [])
  .map(line => line.match(/from\\s+['\\\"]([^'\\\"]+)['\\\"]/)[1])

매칭이 null인 경우를 안전하게 처리하도록 개선하세요:

             const existingExports = new Set(
-              (indexContent.match(/from\\s+['\\\"](\\.\\/|\\.\\.\\/)([^'\\\"]+)['\\\"]/g) || [])
-                .map(line => line.match(/from\\s+['\\\"]([^'\\\"]+)['\\\"]/)[1])
+              (indexContent.match(/from\s+['"]([^'"]+)['"]/g) || [])
+                .map(line => {
+                  const match = line.match(/from\s+['"]([^'"]+)['"]/);
+                  return match ? match[1] : null;
+                })
+                .filter(Boolean)
             );

또한 Line 136의 중복 검사 로직도 개선이 필요합니다. 현재 existingExports.has(exportPath) 는 정확하지만, 만약 이름 기반 검사를 한다면 includes(componentName) 같은 부분 매칭은 "Button"과 "PrimaryButton"을 구분하지 못할 수 있습니다.

🤖 Prompt for AI Agents
In .github/workflows/auto-bump-version.yaml around lines 112 to 139, the current
export-detection uses .match(...).map(...)[1] which can throw if a match is null
and only handles a narrow import/export pattern; also the duplicate check using
includes could produce false positives for similarly named components. Fix by
running the global regex, iterating matches with a loop or Array.from to extract
the captured group only after verifying the match is non-null (guard against
null before accessing [1]), and construct a Set of normalized export paths; then
change the duplicate check to test the exact exportPath (and/or exact
componentName) against that Set (avoid substring/includes checks). Ensure
normalization of paths (remove extensions, resolve './' prefixes) before
comparing.

const componentName = path.basename(relativeFilePath, path.extname(relativeFilePath));
const exportPath = './ui/' + relativeFilePath.replace(path.extname(relativeFilePath), '');
if (existingExports.has(exportPath)) continue;
const line = \`export { \${componentName} } from '\${exportPath}'\`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

export 라인 템플릿에 세미콜론 누락

Line 137의 export 문 끝에 세미콜론이 없습니다:

const line = \`export { \${componentName} } from '\${exportPath}'\`;
//                                                              ↑ 세미콜론 필요

Line 142에서 adds.join(';\n')으로 조합하지만, 코드 일관성과 명확성을 위해 각 라인 끝에 세미콜론을 포함하는 것이 좋습니다:

-              const line = \`export { \${componentName} } from '\${exportPath}'\`;
+              const line = \`export { \${componentName} } from '\${exportPath}';\`;
🤖 Prompt for AI Agents
.github/workflows/auto-bump-version.yaml around line 137: the export line
template misses a trailing semicolon which causes inconsistent formatting when
later joined with adds.join(';\n'); update the template string to include a
trailing semicolon so each export line ends with ";" (e.g. change the
constructed line to append a semicolon at the end), ensuring exported lines are
consistently terminated and the join behavior remains correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] main 브랜치 머지 시 npm 자동 배포 및 버저닝 설정

2 participants