@gracefullight/validate-branch 0.1.0 → 1.0.1
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.en.md +50 -3
- package/README.md +50 -3
- package/dist/cli.js +9 -0
- package/package.json +3 -2
package/README.en.md
CHANGED
|
@@ -130,6 +130,52 @@ module.exports = {
|
|
|
130
130
|
};
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
+
### Using Presets (`branch.config.ts`)
|
|
134
|
+
|
|
135
|
+
You can use built-in presets instead of custom patterns.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import type { Config } from "@gracefullight/validate-branch";
|
|
139
|
+
|
|
140
|
+
const config: Config = {
|
|
141
|
+
preset: "jira", // "gitflow" or "jira"
|
|
142
|
+
description: "JIRA ticket-based branch naming",
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default config;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Available Presets:**
|
|
149
|
+
|
|
150
|
+
#### `gitflow` (default)
|
|
151
|
+
|
|
152
|
+
Pattern following Git Flow branching strategy.
|
|
153
|
+
|
|
154
|
+
| Status | Branch Examples |
|
|
155
|
+
|--------|-----------------|
|
|
156
|
+
| ✅ Allowed | `main`, `master`, `develop`, `stage` |
|
|
157
|
+
| ✅ Allowed | `feature/login`, `feature/user-auth`, `feature/add-payment` |
|
|
158
|
+
| ✅ Allowed | `fix/memory-leak`, `fix/typo`, `fix/null-pointer` |
|
|
159
|
+
| ✅ Allowed | `hotfix/critical-bug`, `hotfix/security-patch` |
|
|
160
|
+
| ✅ Allowed | `release/v1.0.0`, `release/2.3.1` |
|
|
161
|
+
| ❌ Rejected | `login`, `bugfix`, `my-branch` (no prefix) |
|
|
162
|
+
| ❌ Rejected | `feature/`, `fix/` (no name) |
|
|
163
|
+
| ❌ Rejected | `Feature/Login`, `FIX/bug` (uppercase prefix) |
|
|
164
|
+
|
|
165
|
+
#### `jira`
|
|
166
|
+
|
|
167
|
+
JIRA ticket number-based branch pattern.
|
|
168
|
+
|
|
169
|
+
| Status | Branch Examples |
|
|
170
|
+
|--------|-----------------|
|
|
171
|
+
| ✅ Allowed | `main`, `master`, `develop`, `stage` |
|
|
172
|
+
| ✅ Allowed | `FEATURE-123`, `FEATURE-1`, `FEATURE-99999` |
|
|
173
|
+
| ✅ Allowed | `BUG-456`, `STORY-789`, `TASK-101`, `HOTFIX-202` |
|
|
174
|
+
| ❌ Rejected | `feature/login` (gitflow style) |
|
|
175
|
+
| ❌ Rejected | `FEATURE-ABC` (not a number) |
|
|
176
|
+
| ❌ Rejected | `feature-123` (lowercase) |
|
|
177
|
+
| ❌ Rejected | `JIRA-123/description` (contains slash) |
|
|
178
|
+
|
|
133
179
|
## API Reference
|
|
134
180
|
|
|
135
181
|
### `validateBranchName(branchName, options?)`
|
|
@@ -227,9 +273,10 @@ function loadConfig(): Promise<Config | null>
|
|
|
227
273
|
|
|
228
274
|
```typescript
|
|
229
275
|
interface Config {
|
|
230
|
-
pattern?: string;
|
|
231
|
-
patterns?: string[];
|
|
232
|
-
|
|
276
|
+
pattern?: string; // Single regex pattern
|
|
277
|
+
patterns?: string[]; // Multiple regex patterns (planned)
|
|
278
|
+
preset?: "gitflow" | "jira"; // Preset pattern (default: "gitflow")
|
|
279
|
+
description?: string; // Config description
|
|
233
280
|
}
|
|
234
281
|
```
|
|
235
282
|
|
package/README.md
CHANGED
|
@@ -130,6 +130,52 @@ module.exports = {
|
|
|
130
130
|
};
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
+
### 프리셋 사용 (`branch.config.ts`)
|
|
134
|
+
|
|
135
|
+
커스텀 패턴 대신 내장 프리셋을 사용할 수 있습니다.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import type { Config } from "@gracefullight/validate-branch";
|
|
139
|
+
|
|
140
|
+
const config: Config = {
|
|
141
|
+
preset: "jira", // "gitflow" 또는 "jira"
|
|
142
|
+
description: "JIRA 티켓 기반 브랜치 네이밍",
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default config;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**사용 가능한 프리셋:**
|
|
149
|
+
|
|
150
|
+
#### `gitflow` (기본값)
|
|
151
|
+
|
|
152
|
+
Git Flow 브랜치 전략을 따르는 패턴입니다.
|
|
153
|
+
|
|
154
|
+
| 상태 | 브랜치 예시 |
|
|
155
|
+
|------|------------|
|
|
156
|
+
| ✅ 허용 | `main`, `master`, `develop`, `stage` |
|
|
157
|
+
| ✅ 허용 | `feature/login`, `feature/user-auth`, `feature/add-payment` |
|
|
158
|
+
| ✅ 허용 | `fix/memory-leak`, `fix/typo`, `fix/null-pointer` |
|
|
159
|
+
| ✅ 허용 | `hotfix/critical-bug`, `hotfix/security-patch` |
|
|
160
|
+
| ✅ 허용 | `release/v1.0.0`, `release/2.3.1` |
|
|
161
|
+
| ❌ 거부 | `login`, `bugfix`, `my-branch` (prefix 없음) |
|
|
162
|
+
| ❌ 거부 | `feature/`, `fix/` (이름 없음) |
|
|
163
|
+
| ❌ 거부 | `Feature/Login`, `FIX/bug` (대문자 prefix) |
|
|
164
|
+
|
|
165
|
+
#### `jira`
|
|
166
|
+
|
|
167
|
+
JIRA 티켓 번호 기반 브랜치 패턴입니다.
|
|
168
|
+
|
|
169
|
+
| 상태 | 브랜치 예시 |
|
|
170
|
+
|------|------------|
|
|
171
|
+
| ✅ 허용 | `main`, `master`, `develop`, `stage` |
|
|
172
|
+
| ✅ 허용 | `FEATURE-123`, `FEATURE-1`, `FEATURE-99999` |
|
|
173
|
+
| ✅ 허용 | `BUG-456`, `STORY-789`, `TASK-101`, `HOTFIX-202` |
|
|
174
|
+
| ❌ 거부 | `feature/login` (gitflow 스타일) |
|
|
175
|
+
| ❌ 거부 | `FEATURE-ABC` (숫자 아님) |
|
|
176
|
+
| ❌ 거부 | `feature-123` (소문자) |
|
|
177
|
+
| ❌ 거부 | `JIRA-123/description` (슬래시 포함) |
|
|
178
|
+
|
|
133
179
|
## API 레퍼런스
|
|
134
180
|
|
|
135
181
|
### `validateBranchName(branchName, options?)`
|
|
@@ -227,9 +273,10 @@ function loadConfig(): Promise<Config | null>
|
|
|
227
273
|
|
|
228
274
|
```typescript
|
|
229
275
|
interface Config {
|
|
230
|
-
pattern?: string;
|
|
231
|
-
patterns?: string[];
|
|
232
|
-
|
|
276
|
+
pattern?: string; // 단일 정규식 패턴
|
|
277
|
+
patterns?: string[]; // 다중 정규식 패턴 (예정)
|
|
278
|
+
preset?: "gitflow" | "jira"; // 프리셋 패턴 (기본값: "gitflow")
|
|
279
|
+
description?: string; // 설정 설명
|
|
233
280
|
}
|
|
234
281
|
```
|
|
235
282
|
|
package/dist/cli.js
CHANGED
|
@@ -86,6 +86,10 @@ async function loadConfig() {
|
|
|
86
86
|
// src/cli.ts
|
|
87
87
|
var SUCCESS_CODE = 0;
|
|
88
88
|
var FAILED_CODE = 1;
|
|
89
|
+
var PRESET_EXAMPLES = {
|
|
90
|
+
gitflow: ["feature/login", "fix/bug-123", "hotfix/security", "release/v1.0.0"],
|
|
91
|
+
jira: ["FEATURE-123", "BUG-456", "STORY-789", "TASK-101"]
|
|
92
|
+
};
|
|
89
93
|
var program = new Command();
|
|
90
94
|
program.name("validate-branch").description("Git branch name validation tool").version("0.1.0", "-v, --version");
|
|
91
95
|
program.addOption(
|
|
@@ -128,6 +132,11 @@ Validating branch: ${chalk.yellow(branch)}
|
|
|
128
132
|
} else {
|
|
129
133
|
console.error(chalk.red.bold("\u2717 Invalid branch name\n"));
|
|
130
134
|
console.error(chalk.yellow(result.error));
|
|
135
|
+
console.error(chalk.gray("\nExamples of valid branch names:"));
|
|
136
|
+
for (const example of PRESET_EXAMPLES[preset]) {
|
|
137
|
+
console.error(chalk.green(` \u2022 ${example}`));
|
|
138
|
+
}
|
|
139
|
+
console.error();
|
|
131
140
|
process.exit(FAILED_CODE);
|
|
132
141
|
}
|
|
133
142
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gracefullight/validate-branch",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Git branch name validation tool with custom regexp support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
34
|
-
"url": "
|
|
34
|
+
"url": "https://github.com/gracefullight/ts-workspace.git",
|
|
35
|
+
"directory": "packages/validate-branch"
|
|
35
36
|
},
|
|
36
37
|
"license": "MIT",
|
|
37
38
|
"publishConfig": {
|