@seahworks/branch-cli 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SeahWorks
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @seah/branch-cli
2
+
3
+ 세아웍스 Git 브랜치 네이밍 규칙을 준수하는 브랜치를 쉽게 생성하는 CLI 도구입니다.
4
+
5
+ ## 설치
6
+
7
+ ### Yarn (권장)
8
+
9
+ \`\`\`bash
10
+ yarn global add @seah/branch-cli
11
+ \`\`\`
12
+
13
+ ### npm
14
+
15
+ \`\`\`bash
16
+ npm install -g @seah/branch-cli
17
+ \`\`\`
18
+
19
+ ## 사용법
20
+
21
+ Git 저장소 내에서 다음 명령어를 실행하세요:
22
+
23
+ \`\`\`bash
24
+ seah-branch
25
+ \`\`\`
26
+
27
+ 대화형 프롬프트를 따라 다음을 선택/입력합니다:
28
+
29
+ 1. 브랜치 타입 (feature/hotfix/bugfix)
30
+ 2. 모듈 (공통/전자결재/조직도/근태/게시판/관리자/SELIS/SETIS)
31
+ 3. 회사 (세아홀딩스/세아베스틸지주/세아베스틸/세아창원특수강/세아제강지주/세아제강)
32
+ 4. SR/ITS 번호 (예: SR2601-01234)
33
+
34
+ ## 브랜치 네이밍 규칙
35
+
36
+ 생성되는 브랜치는 다음 형식을 따릅니다:
37
+
38
+ \`\`\`
39
+ {type}/{year}/{module}/{company}/{mmdd}-{sr-number}
40
+ \`\`\`
41
+
42
+ **예시:**
43
+ \`\`\`
44
+ feature/2024/appr/aaaa0000000/1229-sr2612-01234
45
+ \`\`\`
46
+
47
+ ## 요구사항
48
+
49
+ - Node.js 22 이상
50
+ - Git
51
+ - Yarn 또는 npm
52
+
53
+ ## 라이선스
54
+
55
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../src/index.js";
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@seahworks/branch-cli",
3
+ "version": "1.0.0",
4
+ "description": "세아웍스 Git 브랜치 네이밍 규칙 준수 도구",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "bin": {
8
+ "seah-branch": "./bin/seah-branch.js"
9
+ },
10
+ "scripts": {
11
+ "test": "node src/index.js",
12
+ "prepublishOnly": "echo '✅ Publishing to npm...'"
13
+ },
14
+ "keywords": [
15
+ "git",
16
+ "branch",
17
+ "cli",
18
+ "seah",
19
+ "naming-convention"
20
+ ],
21
+ "author": "SeahWorks",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "@inquirer/prompts": "^7.2.0",
25
+ "chalk": "^5.3.0"
26
+ },
27
+ "engines": {
28
+ "node": ">=22.0.0"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/mjun94/seah-branch-cli"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/mjun94/seah-branch-cli/issues"
36
+ },
37
+ "homepage": "https://github.com/mjun94/seah-branch-cli#readme",
38
+ "files": [
39
+ "bin",
40
+ "src",
41
+ "README.md",
42
+ "LICENSE"
43
+ ]
44
+ }
package/src/config.js ADDED
@@ -0,0 +1,27 @@
1
+ export const config = {
2
+ branchTypes: [
3
+ { name: "feature - 새 기능", value: "feature" },
4
+ { name: "hotfix - 긴급 수정", value: "hotfix" },
5
+ { name: "bugfix - 버그 수정", value: "bugfix" },
6
+ ],
7
+
8
+ modules: [
9
+ { name: "공통", value: "cmn" },
10
+ { name: "전자결재", value: "appr" },
11
+ { name: "조직도", value: "org" },
12
+ { name: "근태", value: "emp" },
13
+ { name: "게시판", value: "board" },
14
+ { name: "관리자", value: "admin" },
15
+ { name: "SELIS", value: "selis" },
16
+ { name: "SETIS", value: "setis" },
17
+ ],
18
+
19
+ companies: [
20
+ { name: "세아홀딩스", value: "AAAA0000000" },
21
+ { name: "세아베스틸지주", value: "AAMW0000000" },
22
+ { name: "세아베스틸", value: "AAAW0000000" },
23
+ { name: "세아창원특수강", value: "AABW0000000" },
24
+ { name: "세아제강지주", value: "AAEB0000000" },
25
+ { name: "세아제강", value: "AAAB0000000" },
26
+ ],
27
+ };
package/src/index.js ADDED
@@ -0,0 +1,93 @@
1
+ import { select, input, confirm } from "@inquirer/prompts";
2
+ import { execSync } from "child_process";
3
+ import chalk from "chalk";
4
+ import { config } from "./config.js";
5
+
6
+ // 오늘 날짜를 MMDD 형식으로 반환
7
+ function getTodayMMDD() {
8
+ const now = new Date();
9
+ const month = String(now.getMonth() + 1).padStart(2, "0");
10
+ const day = String(now.getDate()).padStart(2, "0");
11
+ return `${month}${day}`;
12
+ }
13
+
14
+ // SR/ITS 번호 검증
15
+ function validateSRNumber(value) {
16
+ const pattern = /^(SR|ITS)\d{4}-\d{5}$/i;
17
+ if (pattern.test(value)) {
18
+ return true;
19
+ }
20
+ return "SR2601-01234 또는 ITS2601-01234 형식으로 입력하세요";
21
+ }
22
+
23
+ async function createBranch() {
24
+ console.log(chalk.blue.bold("\n🌿 세아웍스 브랜치 생성 도구\n"));
25
+
26
+ try {
27
+ // 브랜치 타입 선택
28
+ const type = await select({
29
+ message: "브랜치 타입을 선택하세요:",
30
+ choices: config.branchTypes,
31
+ });
32
+
33
+ // 모듈 선택
34
+ const module = await select({
35
+ message: "모듈을 선택하세요:",
36
+ choices: config.modules,
37
+ });
38
+
39
+ // 회사 선택
40
+ const company = await select({
41
+ message: "회사를 선택하세요:",
42
+ choices: config.companies,
43
+ });
44
+
45
+ // SR/ITS 번호 입력
46
+ const srNumber = await input({
47
+ message: "SR/ITS 번호를 입력하세요 (예: SR2601-01234):",
48
+ validate: validateSRNumber,
49
+ transformer: (value) => value.toUpperCase(),
50
+ });
51
+
52
+ // 브랜치명 생성
53
+ const year = new Date().getFullYear();
54
+ const date = getTodayMMDD();
55
+ const branchName = `${type}/${year}/${module}/${company}/${date}-${srNumber.toLowerCase()}`;
56
+
57
+ console.log(chalk.yellow(`\n생성할 브랜치: ${branchName}\n`));
58
+
59
+ // 확인
60
+ const shouldCreate = await confirm({
61
+ message: "이 브랜치를 생성하시겠습니까?",
62
+ default: true,
63
+ });
64
+
65
+ if (shouldCreate) {
66
+ try {
67
+ execSync(`git checkout -b ${branchName}`, { stdio: "inherit" });
68
+ console.log(chalk.green.bold(`\n✅ 브랜치 생성 완료: ${branchName}\n`));
69
+ } catch (error) {
70
+ console.error(chalk.red("\n❌ 브랜치 생성 실패"));
71
+ console.error(
72
+ chalk.red(
73
+ "Git 저장소인지 확인하거나 이미 존재하는 브랜치명인지 확인하세요.\n"
74
+ )
75
+ );
76
+ process.exit(1);
77
+ }
78
+ } else {
79
+ console.log(chalk.gray("\n취소되었습니다.\n"));
80
+ }
81
+ } catch (error) {
82
+ if (error.name === "ExitPromptError") {
83
+ console.log(chalk.gray("\n\n취소되었습니다.\n"));
84
+ process.exit(0);
85
+ }
86
+ throw error;
87
+ }
88
+ }
89
+
90
+ createBranch().catch((error) => {
91
+ console.error(chalk.red("오류 발생:"), error);
92
+ process.exit(1);
93
+ });