Skip to content

Commit 361ecc7

Browse files
authored
Merge pull request #21 from jaychang99/release/v0.3.2-beta
Release/v0.3.2 beta
2 parents 1dcc3ed + 6cf2b96 commit 361ecc7

File tree

6 files changed

+115
-17
lines changed

6 files changed

+115
-17
lines changed

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"@actions/core": "^1.10.1",
7777
"@slack/web-api": "^7.3.1",
7878
"markdown-it": "^14.1.0",
79-
"openapi-diff-node": "1.1.0"
79+
"openapi-diff-node": "2.0.0"
8080
},
8181
"devDependencies": {
8282
"@jest/globals": "^29.7.0",

src/locale/en-us.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ export const LOCALE_EN_US: Locale = {
2626

2727
description: 'description',
2828
required: 'required',
29-
example: 'example'
29+
example: 'example',
30+
31+
'changed.before': 'Before',
32+
'changed.after': 'After',
33+
'properties.changed': 'Properties changed',
34+
35+
'empty.array': 'Not specified'
3036
}

src/locale/ko-kr.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ export const LOCALE_KO_KR: Locale = {
2626

2727
description: '설명',
2828
required: '필수여부',
29-
example: '예시'
29+
example: '예시',
30+
31+
'changed.before': '변경 전',
32+
'changed.after': '변경 후',
33+
'properties.changed': '변경된 속성',
34+
35+
'empty.array': '없음'
3036
}

src/services/slack.ts

+90-10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class Slack {
7878
diff: DiffOutputItem
7979
): Promise<SendEndpointReturnType> {
8080
const endpoint = `${diff.method.toUpperCase()}: ${diff.path}`
81+
const description = diff.description
8182

8283
const changedParameters = this._getUnchangedItems(diff.queryParams)
8384
const changedRequestBody = this._getUnchangedItems(diff.requestBody)
@@ -150,6 +151,10 @@ export class Slack {
150151
type: 'mrkdwn',
151152
text: `*${translate('endpoint.singular')}:*\n ${endpoint}`
152153
},
154+
{
155+
type: 'mrkdwn',
156+
text: `*${translate('description')}:*\n ${description}`
157+
},
153158
{
154159
type: 'mrkdwn',
155160
text: `*${translate('repository')}: *\n<https://github.com/${
@@ -309,24 +314,94 @@ export class Slack {
309314
})
310315
}
311316

317+
const changeLogElementList: RichTextList[] = []
318+
312319
if (param.changeLogs.length > 0) {
313-
const changeLogElementList: RichTextElement[] = []
320+
changeLogElementList.push({
321+
type: 'rich_text_list',
322+
style: 'bullet',
323+
indent: 0,
324+
border: 1,
325+
elements: [
326+
{
327+
type: 'rich_text_section',
328+
elements: [
329+
{
330+
type: 'text',
331+
text: translate('properties.changed')
332+
}
333+
]
334+
}
335+
]
336+
})
314337

315338
for (const changeLog of param.changeLogs) {
316339
const { field, oldValue, newValue } = changeLog
317340

318341
changeLogElementList.push({
319-
type: 'text',
320-
text: `${field} ${translate(
321-
'status.modified'
322-
)}: ${oldValue} -> ${newValue}`
342+
type: 'rich_text_list',
343+
style: 'bullet',
344+
indent: 1,
345+
border: 1,
346+
elements: [
347+
{
348+
type: 'rich_text_section',
349+
elements: [
350+
{
351+
type: 'text',
352+
text: field
353+
}
354+
]
355+
}
356+
]
323357
})
324-
}
325358

326-
descriptionElements.push({
327-
type: 'rich_text_section',
328-
elements: changeLogElementList
329-
})
359+
let oldValueText = oldValue
360+
let newValueText = newValue
361+
362+
if (Array.isArray(oldValue)) {
363+
if (oldValue.length > 0) {
364+
oldValueText = oldValue.join(', ')
365+
} else {
366+
oldValueText = `(${translate('empty.array')})`
367+
}
368+
}
369+
370+
if (Array.isArray(newValue)) {
371+
if (newValue.length > 0) {
372+
newValueText = newValue.join(', ')
373+
} else {
374+
newValueText = `(${translate('empty.array')})`
375+
}
376+
}
377+
378+
changeLogElementList.push({
379+
type: 'rich_text_list',
380+
style: 'bullet',
381+
indent: 2,
382+
border: 1,
383+
elements: [
384+
{
385+
type: 'rich_text_section',
386+
elements: [
387+
{
388+
type: 'text',
389+
text: `${translate('changed.before')}: \n${oldValueText}`
390+
}
391+
]
392+
},
393+
{
394+
type: 'rich_text_section',
395+
elements: [
396+
{
397+
type: 'text',
398+
text: `${translate('changed.after')}: \n${newValueText}`
399+
}
400+
]
401+
}
402+
]
403+
})
404+
}
330405
}
331406

332407
const description: RichTextList = {
@@ -349,6 +424,11 @@ export class Slack {
349424

350425
elements.push(statusAndEndpoint)
351426
elements.push(description)
427+
428+
if (changeLogElementList.length > 0) {
429+
elements.push(...changeLogElementList)
430+
}
431+
352432
elements.push(newline)
353433
}
354434

src/types/locale.ts

+6
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ export interface Locale {
2525
description: string
2626
required: string
2727
example: string
28+
29+
'changed.before': string
30+
'changed.after': string
31+
'properties.changed': string
32+
33+
'empty.array': string
2834
}

0 commit comments

Comments
 (0)