init
This commit is contained in:
commit
932d4ad420
46 changed files with 5800 additions and 0 deletions
42
lib/sprint.ts
Normal file
42
lib/sprint.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// mime-todo/lib/sprint.ts
|
||||
export interface Sprint {
|
||||
name: string
|
||||
start: string // YYYY-MM-DD
|
||||
end: string // YYYY-MM-DD
|
||||
}
|
||||
|
||||
export function parseSprints(text: string): Sprint[] {
|
||||
const lines = text.split(/\r?\n/)
|
||||
const sprints: Sprint[] = []
|
||||
|
||||
let current: Partial<Sprint> | null = null
|
||||
|
||||
for (const line of lines) {
|
||||
// Start of sprint entry (must not trim indentation)
|
||||
if (/^\s*-\s*(Name:.*)?$/.test(line)) {
|
||||
if (current) sprints.push(current as Sprint)
|
||||
current = {}
|
||||
|
||||
const match = line.match(/^\s*-\s*Name:\s*(.*)$/)
|
||||
if (match) current.name = match[1]
|
||||
continue
|
||||
}
|
||||
|
||||
// Key-value pairs (must be indented)
|
||||
const kv = line.match(/^\s+([A-Za-z][A-Za-z0-9]*):\s*(.*)$/)
|
||||
if (kv && current) {
|
||||
const key = kv[1]
|
||||
const value = kv[2]
|
||||
|
||||
if (key === "Name") current.name = value
|
||||
if (key === "Range") {
|
||||
const [start, end] = value.split("..")
|
||||
current.start = start
|
||||
current.end = end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (current) sprints.push(current as Sprint)
|
||||
return sprints
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue