-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassifyChange.ts
More file actions
48 lines (41 loc) · 1.42 KB
/
classifyChange.ts
File metadata and controls
48 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { VersionBump } from "./detectVersionBump";
import type { SpecChange } from "./diffChangeSet";
export type ChangeClassification = {
level: VersionBump;
reason: string;
};
export function classifyChange<K>(change: SpecChange<K>): ChangeClassification {
const pathStr = change.path.map(String).join(" > ");
const keyStr = String(change.key);
switch (change.type) {
case "removed":
// operation 삭제, 필드 삭제 등
return {
level: "major",
reason: `Removed: ${pathStr} > ${keyStr}`,
};
case "type_changed":
// node, leaf 타입 변경
return {
level: "major",
reason: `Type changed at: ${pathStr} > ${keyStr} (${change.baseNodeType} → ${change.headNodeType})`,
};
case "added":
// 새로운 operation, 필드 추가
return {
level: "minor",
reason: `Added: ${pathStr} > ${keyStr}`,
};
case "modified":
// TODO: required 추가 => major, description 변경 => patch ...
return {
level: "minor",
reason: `Modified: ${pathStr} > ${keyStr}`,
};
default:
return {
level: "patch",
reason: `Unknown change at: ${pathStr} > ${keyStr}`,
};
}
}