@seahworks/branch-cli 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +340 -11
- package/package.json +1 -1
- package/src/index.js +143 -11
package/README.md
CHANGED
|
@@ -1,35 +1,130 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @seahworks/branch-cli
|
|
2
2
|
|
|
3
3
|
세아웍스 Git 브랜치 네이밍 규칙을 준수하는 브랜치를 쉽게 생성하는 CLI 도구입니다.
|
|
4
4
|
|
|
5
|
+
## 주요 기능
|
|
6
|
+
|
|
7
|
+
- ✅ 브랜치 네이밍 규칙 자동 적용
|
|
8
|
+
- ✅ dev_06M/dev_06MON 브랜치에서만 생성 가능
|
|
9
|
+
- ✅ 자동 git fetch 및 동기화 상태 확인
|
|
10
|
+
- ✅ Pull/Push 필요 시 안내 메시지
|
|
11
|
+
- ✅ 대화형 인터페이스로 쉬운 사용
|
|
12
|
+
|
|
5
13
|
## 설치
|
|
6
14
|
|
|
7
15
|
### Yarn (권장)
|
|
8
16
|
|
|
9
17
|
```bash
|
|
10
|
-
yarn global add @
|
|
18
|
+
yarn global add @seahworks/branch-cli
|
|
11
19
|
```
|
|
12
20
|
|
|
13
21
|
### npm
|
|
14
22
|
|
|
15
23
|
```bash
|
|
16
|
-
npm install -g @
|
|
24
|
+
npm install -g @seahworks/branch-cli
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 환경별 추가 설정
|
|
28
|
+
|
|
29
|
+
### Windows - Git Bash 사용자
|
|
30
|
+
|
|
31
|
+
Git Bash에서는 PATH 설정이 추가로 필요합니다:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# 자동 설정 (권장)
|
|
35
|
+
YARN_BIN=$(yarn global bin | sed 's/\\/\//g' | sed 's/C:/\/c/')
|
|
36
|
+
echo "export PATH=\"$YARN_BIN:\$PATH\"" >> ~/.bashrc
|
|
37
|
+
source ~/.bashrc
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**수동 설정:**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# 1. .bashrc 편집
|
|
44
|
+
nano ~/.bashrc
|
|
45
|
+
|
|
46
|
+
# 2. 파일 맨 아래에 추가 (YourName을 실제 사용자명으로 변경)
|
|
47
|
+
export PATH="/c/Users/YourName/AppData/Local/Yarn/bin:$PATH"
|
|
48
|
+
|
|
49
|
+
# 3. 저장 후 적용
|
|
50
|
+
source ~/.bashrc
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Windows - PowerShell/CMD 사용자
|
|
54
|
+
|
|
55
|
+
1. `Win + R` → `sysdm.cpl` 입력 → Enter
|
|
56
|
+
2. **고급** 탭 → **환경 변수** 클릭
|
|
57
|
+
3. **사용자 변수**에서 **Path** 선택 → **편집**
|
|
58
|
+
4. **새로 만들기** 클릭
|
|
59
|
+
5. `yarn global bin` 명령어 결과 경로 입력
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
C:\Users\YourName\AppData\Local\Yarn\bin
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
6. **확인** 후 **PowerShell/CMD 재시작**
|
|
66
|
+
|
|
67
|
+
### macOS / Linux
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Zsh (macOS 기본)
|
|
71
|
+
echo 'export PATH="$(yarn global bin):$PATH"' >> ~/.zshrc
|
|
72
|
+
source ~/.zshrc
|
|
73
|
+
|
|
74
|
+
# Bash
|
|
75
|
+
echo 'export PATH="$(yarn global bin):$PATH"' >> ~/.bashrc
|
|
76
|
+
source ~/.bashrc
|
|
17
77
|
```
|
|
18
78
|
|
|
19
79
|
## 사용법
|
|
20
80
|
|
|
21
|
-
|
|
81
|
+
### 1. dev 브랜치로 이동
|
|
82
|
+
|
|
83
|
+
**중요:** 브랜치 생성은 `dev_06M` 또는 `dev_06MON` 브랜치에서만 가능합니다.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
git checkout dev_06M
|
|
87
|
+
# 또는
|
|
88
|
+
git checkout dev_06MON
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 2. CLI 도구 실행
|
|
22
92
|
|
|
23
93
|
```bash
|
|
24
|
-
|
|
94
|
+
-branch
|
|
25
95
|
```
|
|
26
96
|
|
|
27
|
-
|
|
97
|
+
도구가 자동으로 다음을 확인합니다:
|
|
98
|
+
|
|
99
|
+
- ✅ 현재 브랜치가 dev_06M 또는 dev_06MON인지 검증
|
|
100
|
+
- ✅ 원격 저장소에서 최신 정보 가져오기 (`git fetch`)
|
|
101
|
+
- ✅ Pull/Push가 필요한지 확인
|
|
102
|
+
|
|
103
|
+
### 3. 브랜치 정보 입력
|
|
104
|
+
|
|
105
|
+
대화형 프롬프트에 따라 선택/입력:
|
|
106
|
+
|
|
107
|
+
1. **브랜치 타입**
|
|
108
|
+
|
|
109
|
+
- feature (새 기능)
|
|
110
|
+
- hotfix (긴급 수정)
|
|
111
|
+
- bugfix (버그 수정)
|
|
112
|
+
|
|
113
|
+
2. **모듈**
|
|
114
|
+
|
|
115
|
+
- 공통, 전자결재, 조직도, 근태, 게시판, 관리자, SELIS, SETIS
|
|
116
|
+
|
|
117
|
+
3. **회사**
|
|
118
|
+
|
|
119
|
+
- 세아홀딩스, 세아베스틸지주, 세아베스틸, 세아창원특수강, 세아제강지주, 세아제강, 기타
|
|
28
120
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
121
|
+
4. **SR/ITS 또는 티켓 번호** (선택사항)
|
|
122
|
+
- 예: `SR2601-01234`
|
|
123
|
+
- 없으면 Enter
|
|
124
|
+
|
|
125
|
+
### 4. 브랜치 생성 완료
|
|
126
|
+
|
|
127
|
+
확인 후 새 브랜치가 자동으로 생성되고 체크아웃됩니다.
|
|
33
128
|
|
|
34
129
|
## 브랜치 네이밍 규칙
|
|
35
130
|
|
|
@@ -39,17 +134,251 @@ seah-branch
|
|
|
39
134
|
{type}/{year}/{module}/{company}/{mmdd}-{sr-number}
|
|
40
135
|
```
|
|
41
136
|
|
|
42
|
-
|
|
137
|
+
### 예시
|
|
138
|
+
|
|
139
|
+
**티켓 번호가 있는 경우:**
|
|
43
140
|
|
|
44
141
|
```
|
|
45
142
|
feature/2024/appr/aaaa0000000/1229-sr2612-01234
|
|
46
143
|
```
|
|
47
144
|
|
|
145
|
+
**티켓 번호가 없는 경우:**
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
feature/2024/board/etc/1229
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 구성 요소
|
|
152
|
+
|
|
153
|
+
- `type`: feature, hotfix, bugfix
|
|
154
|
+
- `year`: 자동으로 현재 연도 (예: 2024)
|
|
155
|
+
- `module`: cmn, appr, org, emp, board, admin, selis, setis
|
|
156
|
+
- `company`: aaaa0000000, aamw0000000, aaaw0000000, aabw0000000, aaeb0000000, aaab0000000, etc
|
|
157
|
+
- `mmdd`: 자동으로 오늘 날짜 (예: 1229)
|
|
158
|
+
- `sr-number`: SR2601-01234 또는 ITS2601-01234 (선택사항)
|
|
159
|
+
|
|
160
|
+
## 실행 시나리오
|
|
161
|
+
|
|
162
|
+
### ✅ 정상 진행
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
$ -branch
|
|
166
|
+
|
|
167
|
+
🌿 세아웍스 브랜치 생성 도구
|
|
168
|
+
|
|
169
|
+
현재 브랜치: dev_06M
|
|
170
|
+
|
|
171
|
+
✅ dev_06M 브랜치에서 실행 중
|
|
172
|
+
|
|
173
|
+
🔄 원격 저장소에서 최신 정보를 가져오는 중...
|
|
174
|
+
|
|
175
|
+
✅ 브랜치가 최신 상태입니다.
|
|
176
|
+
|
|
177
|
+
? 브랜치 타입을 선택하세요: feature - 새 기능
|
|
178
|
+
? 모듈을 선택하세요: 전자결재
|
|
179
|
+
? 회사를 선택하세요: 세아홀딩스
|
|
180
|
+
? SR/ITS 또는 티켓 번호를 입력하세요: SR2601-01234
|
|
181
|
+
|
|
182
|
+
생성할 브랜치: feature/2024/appr/aaaa0000000/1229-sr2601-01234
|
|
183
|
+
|
|
184
|
+
? 이 브랜치를 생성하시겠습니까? Yes
|
|
185
|
+
|
|
186
|
+
✅ 브랜치 생성 완료: feature/2024/appr/aaaa0000000/1229-sr2601-01234
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### ❌ dev 브랜치가 아닌 경우
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
$ -branch
|
|
193
|
+
|
|
194
|
+
🌿 세아웍스 브랜치 생성 도구
|
|
195
|
+
|
|
196
|
+
현재 브랜치: main
|
|
197
|
+
|
|
198
|
+
❌ 브랜치 생성은 dev_06M 또는 dev_06MON 브랜치에서만 가능합니다.
|
|
199
|
+
|
|
200
|
+
다음 명령어로 브랜치를 변경한 후 다시 실행하세요:
|
|
201
|
+
git checkout dev_06M
|
|
202
|
+
또는
|
|
203
|
+
git checkout dev_06MON
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### ⚠️ Pull이 필요한 경우
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
$ -branch
|
|
210
|
+
|
|
211
|
+
🌿 세아웍스 브랜치 생성 도구
|
|
212
|
+
|
|
213
|
+
현재 브랜치: dev_06M
|
|
214
|
+
|
|
215
|
+
✅ dev_06M 브랜치에서 실행 중
|
|
216
|
+
|
|
217
|
+
🔄 원격 저장소에서 최신 정보를 가져오는 중...
|
|
218
|
+
|
|
219
|
+
⚠️ 브랜치 동기화 필요
|
|
220
|
+
|
|
221
|
+
❌ 원격 저장소에 3개의 새로운 커밋이 있습니다.
|
|
222
|
+
다음 명령어로 최신 변경사항을 받아오세요:
|
|
223
|
+
git pull origin dev_06M
|
|
224
|
+
|
|
225
|
+
동기화 후 다시 실행해주세요.
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### ⚠️ Push가 필요한 경우
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
$ -branch
|
|
232
|
+
|
|
233
|
+
🌿 세아웍스 브랜치 생성 도구
|
|
234
|
+
|
|
235
|
+
현재 브랜치: dev_06MON
|
|
236
|
+
|
|
237
|
+
✅ dev_06MON 브랜치에서 실행 중
|
|
238
|
+
|
|
239
|
+
🔄 원격 저장소에서 최신 정보를 가져오는 중...
|
|
240
|
+
|
|
241
|
+
⚠️ 브랜치 동기화 필요
|
|
242
|
+
|
|
243
|
+
❌ 로컬에 2개의 푸시되지 않은 커밋이 있습니다.
|
|
244
|
+
다음 명령어로 변경사항을 푸시하세요:
|
|
245
|
+
git push origin dev_06MON
|
|
246
|
+
|
|
247
|
+
동기화 후 다시 실행해주세요.
|
|
248
|
+
```
|
|
249
|
+
|
|
48
250
|
## 요구사항
|
|
49
251
|
|
|
50
252
|
- Node.js 18 이상
|
|
51
253
|
- Git
|
|
52
254
|
- Yarn 또는 npm
|
|
255
|
+
- dev_06M 또는 dev_06MON 브랜치
|
|
256
|
+
|
|
257
|
+
## 업데이트
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Yarn
|
|
261
|
+
yarn global upgrade @/branch-cli
|
|
262
|
+
|
|
263
|
+
# npm
|
|
264
|
+
npm update -g @/branch-cli
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## 문제 해결
|
|
268
|
+
|
|
269
|
+
### command not found: -branch
|
|
270
|
+
|
|
271
|
+
#### Windows - Git Bash
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# PATH 확인
|
|
275
|
+
echo $PATH | grep -i yarn
|
|
276
|
+
|
|
277
|
+
# PATH 추가
|
|
278
|
+
YARN_BIN=$(yarn global bin | sed 's/\\/\//g' | sed 's/C:/\/c/')
|
|
279
|
+
echo "export PATH=\"$YARN_BIN:\$PATH\"" >> ~/.bashrc
|
|
280
|
+
source ~/.bashrc
|
|
281
|
+
|
|
282
|
+
# 확인
|
|
283
|
+
-branch
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### Windows - PowerShell/CMD
|
|
287
|
+
|
|
288
|
+
1. PowerShell을 **완전히 종료** 후 **새로 열기**
|
|
289
|
+
2. 그래도 안 되면 **PC 재부팅**
|
|
290
|
+
3. 여전히 안 되면 환경 변수 설정 다시 확인
|
|
291
|
+
|
|
292
|
+
#### macOS / Linux
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# PATH 추가 및 저장
|
|
296
|
+
echo 'export PATH="$(yarn global bin):$PATH"' >> ~/.zshrc # Zsh
|
|
297
|
+
# 또는
|
|
298
|
+
echo 'export PATH="$(yarn global bin):$PATH"' >> ~/.bashrc # Bash
|
|
299
|
+
|
|
300
|
+
# 적용
|
|
301
|
+
source ~/.zshrc # 또는 source ~/.bashrc
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Node.js 버전 확인
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
node --version
|
|
308
|
+
# v18.0.0 이상이어야 합니다
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**업데이트 방법:**
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# nvm 사용 시
|
|
315
|
+
nvm install 18
|
|
316
|
+
nvm use 18
|
|
317
|
+
|
|
318
|
+
# 공식 사이트 다운로드
|
|
319
|
+
# https://nodejs.org
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Git 저장소가 아닙니다
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
❌ Git 저장소가 아니거나 브랜치를 확인할 수 없습니다.
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**해결:**
|
|
329
|
+
|
|
330
|
+
- Git 저장소 디렉토리에서 실행하세요
|
|
331
|
+
- `git init` 또는 `git clone`으로 저장소 생성
|
|
332
|
+
|
|
333
|
+
### 임시 해결책
|
|
334
|
+
|
|
335
|
+
PATH 설정이 어려운 경우:
|
|
336
|
+
|
|
337
|
+
#### npx 사용 (npm 설치 시)
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
npx @/branch-cli
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
#### 전체 경로로 실행
|
|
344
|
+
|
|
345
|
+
**Windows - Git Bash:**
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
"/c/Users/YourName/AppData/Local/Yarn/bin/-branch"
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Windows - PowerShell/CMD:**
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
C:\Users\YourName\AppData\Local\Yarn\bin\-branch
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**macOS / Linux:**
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
$(yarn global bin)/-branch
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
#### package.json 스크립트
|
|
364
|
+
|
|
365
|
+
프로젝트 `package.json`에 추가:
|
|
366
|
+
|
|
367
|
+
```json
|
|
368
|
+
{
|
|
369
|
+
"scripts": {
|
|
370
|
+
"branch": "-branch"
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
실행:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
yarn branch
|
|
379
|
+
# 또는
|
|
380
|
+
npm run branch
|
|
381
|
+
```
|
|
53
382
|
|
|
54
383
|
## 라이선스
|
|
55
384
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -13,21 +13,157 @@ function getTodayMMDD() {
|
|
|
13
13
|
|
|
14
14
|
// SR/ITS 번호 검증
|
|
15
15
|
function validateSRNumber(value) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 현재 브랜치 가져오기
|
|
20
|
+
function getCurrentBranch() {
|
|
21
|
+
try {
|
|
22
|
+
const branch = execSync("git branch --show-current", {
|
|
23
|
+
encoding: "utf-8",
|
|
24
|
+
}).trim();
|
|
25
|
+
return branch;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error(
|
|
28
|
+
chalk.red("❌ Git 저장소가 아니거나 브랜치를 확인할 수 없습니다.")
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
19
31
|
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// dev_06M 또는 dev_06MON 브랜치인지 확인
|
|
35
|
+
function isDevBranch(branchName) {
|
|
36
|
+
return branchName === "dev_06M" || branchName === "dev_06MON";
|
|
37
|
+
}
|
|
20
38
|
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
// Git fetch 실행
|
|
40
|
+
function gitFetch() {
|
|
41
|
+
try {
|
|
42
|
+
console.log(chalk.blue("🔄 원격 저장소에서 최신 정보를 가져오는 중..."));
|
|
43
|
+
execSync("git fetch", { stdio: "inherit" });
|
|
23
44
|
return true;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(chalk.red("❌ git fetch 실패"));
|
|
47
|
+
return false;
|
|
24
48
|
}
|
|
25
|
-
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 로컬과 원격 브랜치 비교
|
|
52
|
+
function checkBranchStatus(branchName) {
|
|
53
|
+
try {
|
|
54
|
+
// 원격 브랜치가 존재하는지 확인
|
|
55
|
+
const remoteBranch = `origin/${branchName}`;
|
|
56
|
+
try {
|
|
57
|
+
execSync(`git rev-parse --verify ${remoteBranch}`, { stdio: "pipe" });
|
|
58
|
+
} catch {
|
|
59
|
+
// 원격 브랜치가 없으면 로컬 전용 브랜치
|
|
60
|
+
return { canProceed: true, needsPull: false, needsPush: false };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 로컬과 원격 커밋 비교
|
|
64
|
+
const localCommit = execSync(`git rev-parse ${branchName}`, {
|
|
65
|
+
encoding: "utf-8",
|
|
66
|
+
}).trim();
|
|
67
|
+
const remoteCommit = execSync(`git rev-parse ${remoteBranch}`, {
|
|
68
|
+
encoding: "utf-8",
|
|
69
|
+
}).trim();
|
|
70
|
+
|
|
71
|
+
if (localCommit === remoteCommit) {
|
|
72
|
+
// 동기화 상태
|
|
73
|
+
return { canProceed: true, needsPull: false, needsPush: false };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ahead/behind 확인
|
|
77
|
+
const ahead = execSync(
|
|
78
|
+
`git rev-list --count ${remoteBranch}..${branchName}`,
|
|
79
|
+
{ encoding: "utf-8" }
|
|
80
|
+
).trim();
|
|
81
|
+
const behind = execSync(
|
|
82
|
+
`git rev-list --count ${branchName}..${remoteBranch}`,
|
|
83
|
+
{ encoding: "utf-8" }
|
|
84
|
+
).trim();
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
canProceed: false,
|
|
88
|
+
needsPull: parseInt(behind) > 0,
|
|
89
|
+
needsPush: parseInt(ahead) > 0,
|
|
90
|
+
aheadCount: parseInt(ahead),
|
|
91
|
+
behindCount: parseInt(behind),
|
|
92
|
+
};
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error(chalk.yellow("⚠️ 브랜치 상태 확인 중 오류 발생"));
|
|
95
|
+
return { canProceed: true, needsPull: false, needsPush: false };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 브랜치 검증 및 준비
|
|
100
|
+
async function validateAndPrepareBranch() {
|
|
101
|
+
const currentBranch = getCurrentBranch();
|
|
102
|
+
|
|
103
|
+
console.log(chalk.blue(`현재 브랜치: ${currentBranch}\n`));
|
|
104
|
+
|
|
105
|
+
// 1. dev_06M 또는 dev_06MON이 아닌 경우
|
|
106
|
+
if (!isDevBranch(currentBranch)) {
|
|
107
|
+
console.log(
|
|
108
|
+
chalk.red(
|
|
109
|
+
"❌ 브랜치 생성은 dev_06M 또는 dev_06MON 브랜치에서만 가능합니다.\n"
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
console.log(
|
|
113
|
+
chalk.yellow("다음 명령어로 브랜치를 변경한 후 다시 실행하세요:")
|
|
114
|
+
);
|
|
115
|
+
console.log(chalk.cyan(" git checkout dev_06M"));
|
|
116
|
+
console.log(chalk.cyan(" 또는"));
|
|
117
|
+
console.log(chalk.cyan(" git checkout dev_06MON\n"));
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 2. dev_06M 또는 dev_06MON인 경우 - fetch 실행
|
|
122
|
+
console.log(chalk.green(`✅ ${currentBranch} 브랜치에서 실행 중\n`));
|
|
123
|
+
|
|
124
|
+
if (!gitFetch()) {
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 3. pull/push 필요 여부 확인
|
|
129
|
+
const status = checkBranchStatus(currentBranch);
|
|
130
|
+
|
|
131
|
+
if (!status.canProceed) {
|
|
132
|
+
console.log(chalk.yellow("\n⚠️ 브랜치 동기화 필요\n"));
|
|
133
|
+
|
|
134
|
+
if (status.needsPull) {
|
|
135
|
+
console.log(
|
|
136
|
+
chalk.red(
|
|
137
|
+
`❌ 원격 저장소에 ${status.behindCount}개의 새로운 커밋이 있습니다.`
|
|
138
|
+
)
|
|
139
|
+
);
|
|
140
|
+
console.log(chalk.yellow("다음 명령어로 최신 변경사항을 받아오세요:"));
|
|
141
|
+
console.log(chalk.cyan(` git pull origin ${currentBranch}\n`));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (status.needsPush) {
|
|
145
|
+
console.log(
|
|
146
|
+
chalk.red(
|
|
147
|
+
`❌ 로컬에 ${status.aheadCount}개의 푸시되지 않은 커밋이 있습니다.`
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
console.log(chalk.yellow("다음 명령어로 변경사항을 푸시하세요:"));
|
|
151
|
+
console.log(chalk.cyan(` git push origin ${currentBranch}\n`));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
console.log(chalk.yellow("동기화 후 다시 실행해주세요.\n"));
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
console.log(chalk.green("✅ 브랜치가 최신 상태입니다.\n"));
|
|
26
159
|
}
|
|
27
160
|
|
|
28
161
|
async function createBranch() {
|
|
29
162
|
console.log(chalk.blue.bold("\n🌿 세아웍스 브랜치 생성 도구\n"));
|
|
30
163
|
|
|
164
|
+
// 브랜치 검증 및 준비
|
|
165
|
+
await validateAndPrepareBranch();
|
|
166
|
+
|
|
31
167
|
try {
|
|
32
168
|
// 브랜치 타입 선택
|
|
33
169
|
const type = await select({
|
|
@@ -85,11 +221,7 @@ async function createBranch() {
|
|
|
85
221
|
console.log(chalk.green.bold(`\n✅ 브랜치 생성 완료: ${branchName}\n`));
|
|
86
222
|
} catch (error) {
|
|
87
223
|
console.error(chalk.red("\n❌ 브랜치 생성 실패"));
|
|
88
|
-
console.error(
|
|
89
|
-
chalk.red(
|
|
90
|
-
"Git 저장소인지 확인하거나 이미 존재하는 브랜치명인지 확인하세요.\n"
|
|
91
|
-
)
|
|
92
|
-
);
|
|
224
|
+
console.error(chalk.red("이미 존재하는 브랜치명인지 확인하세요.\n"));
|
|
93
225
|
process.exit(1);
|
|
94
226
|
}
|
|
95
227
|
} else {
|