Skip to content

Commit 33d2f19

Browse files
committed
feat: update report format
1 parent 4433966 commit 33d2f19

1 file changed

Lines changed: 105 additions & 25 deletions

File tree

β€Žpackages/scripts/src/utils/report.tsβ€Ž

Lines changed: 105 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ const sortedStatusValues = [
1818
'βœ… Done',
1919
]
2020

21+
const statusDisplayMap = {
22+
'πŸ†• New': 'πŸ†• **New**',
23+
'πŸ“«Hold On': '⏸️ **On Hold**',
24+
'πŸ“‹ Backlog': 'πŸ“‹ **Backlog**',
25+
'πŸ“ŒPlanning': 'πŸ“Œ **Planning**',
26+
'🎨 Designing': '🎨 **Designing**',
27+
'πŸ— In Progress': 'πŸ— **In Progress**',
28+
'πŸ”Ž Code Review': 'πŸ” **Code Review**',
29+
'πŸ‘€ Testing': 'πŸ§ͺ **Testing**',
30+
'🚩Pre Release': 'πŸš€ **Pre-Release**',
31+
'βœ… Done': 'βœ… **Done**',
32+
}
33+
2134
const folder = join(process.cwd(), 'snapshots')
2235
const currentFilepath = join(folder, 'current.json')
2336
const prevFilepath = join(folder, 'prev.json')
@@ -46,9 +59,17 @@ export function generateDevlogFromSnapshotsDiff() {
4659

4760
let devLog = ''
4861

62+
const reportDate = new Date().toISOString().slice(0, 10)
63+
devLog += `# πŸ“Š Development Progress Report\n\n`
64+
devLog += `**Date:** ${reportDate}\n`
65+
devLog += `**Generated:** ${new Date().toLocaleString()}\n\n`
66+
67+
let totalNew = 0
68+
let totalUpdates = 0
69+
let totalCompleted = 0
70+
4971
for (const [title, currentItems] of Object.entries(currentProjectItemsMap)) {
50-
const prevItems = prevProjectItemsMap[title]
51-
if (!prevItems) continue
72+
const prevItems = prevProjectItemsMap[title] ?? []
5273

5374
const currentMap = itemsToItemMap(currentItems)
5475
const prevMap = itemsToItemMap(prevItems)
@@ -59,6 +80,9 @@ export function generateDevlogFromSnapshotsDiff() {
5980

6081
for (const id of Object.keys(currentMap)) {
6182
const currentItem = currentMap[id]
83+
84+
if (!currentItem?.content?.title) continue
85+
6286
const prevItem = prevMap[id]
6387
assert(currentItem)
6488

@@ -85,6 +109,9 @@ export function generateDevlogFromSnapshotsDiff() {
85109
}
86110
}
87111

112+
totalNew += newItems.length
113+
totalUpdates += update.length
114+
totalCompleted += done.length
88115
;[newItems, update, done].forEach(items =>
89116
items.sort((a, b) => {
90117
const aStatus = getField(a, 'Status')?.name ?? 'πŸ†• New'
@@ -94,59 +121,112 @@ export function generateDevlogFromSnapshotsDiff() {
94121
)
95122

96123
const getStatusChangeLog = (item: ProjectItem) => {
97-
const currentStatus = getField(item, 'Status')?.name
124+
const currentStatus = getField(item, 'Status')?.name ?? 'πŸ€– Unset'
98125
const prevItem = prevMap[item.id]
99126
const prevStatus = prevItem == null ? undefined : getField(prevItem, 'Status')?.name
100-
if (prevStatus == null || currentStatus === prevStatus) return ` [${currentStatus}]`
101-
return ` [${prevStatus} -> ${currentStatus}]`
127+
128+
if (prevStatus == null || currentStatus === prevStatus) {
129+
return `**${statusDisplayMap[currentStatus as keyof typeof statusDisplayMap] || currentStatus}**`
130+
}
131+
return `**${statusDisplayMap[prevStatus as keyof typeof statusDisplayMap] || prevStatus}** β†’ **${
132+
statusDisplayMap[currentStatus as keyof typeof statusDisplayMap] || currentStatus
133+
}**`
102134
}
103135

104136
const getContentURL = (item: ProjectItem) =>
105137
item.content.url != null ? ` [#${item.content.number}](${item.content.url})` : ''
106138

107-
const getDescription = (item: ProjectItem) => {
108-
const desc = getField(item, 'Description')?.text
109-
return desc != null ? ` [${desc}]` : ''
139+
const getPriority = (item: ProjectItem) => {
140+
const priority = getField(item, 'Priority')?.name
141+
if (!priority) return ''
142+
143+
const priorityMap = {
144+
High: 'πŸŸ₯',
145+
Medium: '🟨',
146+
Low: '🟩',
147+
Urgent: '🚨',
148+
}
149+
return ` ${priorityMap[priority as keyof typeof priorityMap] || ''}`
110150
}
111151

112-
devLog += `# ${title}\n\n`
152+
const getLabels = (item: ProjectItem) => {
153+
const labels = getField(item, 'Labels')?.name
154+
if (!labels) return ''
155+
return ` \`${labels}\``
156+
}
157+
158+
devLog += `### ${title}\n\n`
113159

114160
if ([newItems, update, done].every(items => items.length === 0)) {
115-
devLog += `## No updates\n\n`
161+
devLog += `#### πŸ“Š No Updates\n\n*No changes detected in this project since the last snapshot.*\n\n`
116162
continue
117163
}
118164

119165
if (newItems.length > 0) {
120-
devLog += '## [NEW]\n\n'
121-
newItems.forEach((item, idx) => {
122-
devLog += `${idx + 1}. ${item.content.title}${getContentURL(item)}${getDescription(item)}\n`
166+
devLog += '#### πŸ†• New Items\n\n'
167+
devLog += '| Status | Title | Issue |\n'
168+
devLog += '|--------|-------|-------|\n'
169+
newItems.forEach(item => {
170+
const status = getStatusChangeLog(item)
171+
const title = item.content.title
172+
const issue = getContentURL(item)
173+
const priority = getPriority(item)
174+
const labels = getLabels(item)
175+
devLog += `| ${status} | ${title}${priority}${labels} | ${issue} |\n`
123176
})
124177
devLog += '\n'
125178
}
126179

127180
if (update.length > 0) {
128-
devLog += '## [UPDATE]\n\n'
129-
update.forEach((item, idx) => {
130-
devLog += `${idx + 1}.${getStatusChangeLog(item)} ${item.content.title}${getContentURL(item)}${getDescription(
131-
item,
132-
)}\n`
181+
devLog += '#### πŸ”„ Updates\n\n'
182+
devLog += '| Status Change | Title | Issue |\n'
183+
devLog += '|---------------|-------|-------|\n'
184+
update.forEach(item => {
185+
const statusChange = getStatusChangeLog(item)
186+
const title = item.content.title
187+
const issue = getContentURL(item)
188+
const priority = getPriority(item)
189+
const labels = getLabels(item)
190+
devLog += `| ${statusChange} | ${title}${priority}${labels} | ${issue} |\n`
133191
})
134192
devLog += '\n'
135193
}
136194

137195
if (done.length > 0) {
138-
devLog += '## [DONE]\n\n'
139-
done.forEach((item, idx) => {
140-
devLog += `${idx + 1}. [${getField(item, 'Status')?.name}] ${item.content.title}${getContentURL(
141-
item,
142-
)}${getDescription(item)}\n`
196+
devLog += '#### βœ… Completed\n\n'
197+
devLog += '| Final Status | Title | Issue |\n'
198+
devLog += '|--------------|-------|-------|\n'
199+
done.forEach(item => {
200+
const finalStatus = `**${
201+
statusDisplayMap[getField(item, 'Status')?.name as keyof typeof statusDisplayMap] ||
202+
getField(item, 'Status')?.name
203+
}**`
204+
const title = item.content.title
205+
const issue = getContentURL(item)
206+
const priority = getPriority(item)
207+
const labels = getLabels(item)
208+
devLog += `| ${finalStatus} | ${title}${priority}${labels} | ${issue} |\n`
143209
})
144210
}
145211

146-
devLog += '\n'
212+
devLog += '\n---\n\n'
147213
}
148214

149-
return devLog
215+
const summary = `## πŸ“ˆ Summary\n\n`
216+
const summaryTable = `| Metric | Count |\n|--------|-------|\n`
217+
const summaryRows = [
218+
`| πŸ†• New Items | ${totalNew} |`,
219+
`| πŸ”„ Updates | ${totalUpdates} |`,
220+
`| βœ… Completed | ${totalCompleted} |`,
221+
`| πŸ“Š Total Changes | ${totalNew + totalUpdates + totalCompleted} |`,
222+
].join('\n')
223+
224+
const finalDevLog = devLog.replace(
225+
'# πŸ“Š Development Progress Report',
226+
`# πŸ“Š Development Progress Report\n\n${summary}${summaryTable}${summaryRows}\n\n---\n\n## πŸ“‹ Project Details`,
227+
)
228+
229+
return finalDevLog
150230
}
151231

152232
export async function createDevlogDiscussion() {

0 commit comments

Comments
Β (0)