Skip to content

feat: 하나의 파일 변경점이 2개 이상의 워크스페이스에 매핑되면 에러를 발생시키도록 합니다#20

Open
ato-m-a wants to merge 3 commits intotoss:mainfrom
ato-m-a:fix-nested-workspaces-match-files
Open

feat: 하나의 파일 변경점이 2개 이상의 워크스페이스에 매핑되면 에러를 발생시키도록 합니다#20
ato-m-a wants to merge 3 commits intotoss:mainfrom
ato-m-a:fix-nested-workspaces-match-files

Conversation

@ato-m-a
Copy link
Copy Markdown

@ato-m-a ato-m-a commented Apr 19, 2026

배경

nested workspace가 존재하는 경우, 하나의 파일 변경점이 매칭된 여러 워크스페이스 경로 prefix에 매칭됩니다. 배열 순서에 따라 먼저 발견되는 워크스페이스에 매핑되어 비결정적인 결과를 주는 대신 에러를 발생시키도록 합니다.

독립적으로 빌드/릴리즈되는 패키지를 관리하는 저장소더라도

packages/root
 └ packages/nested-a
 └ packages/nested-b

와 같은 어색한 워크스페이스 구조 대신,

 └ packages/core
 └ packages/adapter-a
 └ packages/adapter-b

와 같이 자연스러운 워크스페이스 구조를 권장합니다.

빌드 오케스트레이션 등 하위 패키지들을 대상으로 하는 관리 스크립트를 묶기 위한 상위 패키지가 존재한다면 workspace 배열에서 명시적으로 exclude해 workspace 멤버로 등록하지 않는 것을 권장합니다.

{
  "workspaces": [
    "packages/**",
+. "!packages/root",
  ],
}

변경

matchWorkspacesByFiles.ts 수정

하나의 파일이 2개 이상의 워크스페이스에 매핑되면 에러를 발생시키도록 변경합니다.

getUpdatedWorkspaces.test.ts 테스트 케이스 추가

의존성 그래프 기반 변경 감지를 검증하는 통합 테스트 케이스를 추가했습니다.

  • 변경된 워크스페이스를 workspace:*로 의존하는 워크스페이스가 결과에 포함된다
  • 간접적으로 의존하는 워크스페이스도 결과에 포함된다

테스트 증적

image image

return files
.map(file => {
return workspaces.find(workspace => file.startsWith(`${workspace}/`));
return sortedWorkspaces.find(workspace => file.startsWith(`${workspace}/`));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return sortedWorkspaces.find(workspace => file.startsWith(`${workspace}/`));
const workspaces = sortedWorkspaces.filter(workspace => file.startsWith(`${workspace}/`));
if (workspaces.length > 1) {
throw new Error('Nested workspaces are not supported');
}
return workspaces[0];

@ato-m-a ato-m-a changed the title fix: nested workspace의 파일이 상위 workspace가 아닌 정확한 workspace에 매핑되도록 합니다 feat: 하나의 파일 변경점이 2개 이상의 워크스페이스에 매핑되면 에러를 발생시키도록 합니다 Apr 22, 2026
@ato-m-a ato-m-a requested a review from raon0211 April 22, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants