Skip to content

Commit 0350089

Browse files
authored
Merge pull request #16 from jaychang99/release/v0.3.0-beta
Release/v0.3.0 beta
2 parents c01a826 + 0f3c51f commit 0350089

File tree

6 files changed

+112
-30
lines changed

6 files changed

+112
-30
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.0.1"
79+
"openapi-diff-node": "1.1.0"
8080
},
8181
"devDependencies": {
8282
"@jest/globals": "^29.7.0",

src/locale/en-us.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ export const LOCALE_EN_US: Locale = {
2222

2323
repository: 'Repository',
2424

25-
'exception.missing-description': 'No description provided. Please add one'
25+
'exception.missing-description': 'No description provided. Please add one',
26+
27+
description: 'description',
28+
required: 'required',
29+
example: 'example'
2630
}

src/locale/ko-kr.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ export const LOCALE_KO_KR: Locale = {
2222

2323
repository: '저장소',
2424

25-
'exception.missing-description': '설명이 없습니다. 추가해주세요'
25+
'exception.missing-description': '설명이 없습니다. 추가해주세요',
26+
27+
description: '설명',
28+
required: '필수여부',
29+
example: '예시'
2630
}

src/services/slack.ts

+93-23
Original file line numberDiff line numberDiff line change
@@ -237,34 +237,104 @@ export class Slack {
237237
]
238238
}
239239

240+
let required = ''
241+
if (param.required === true) {
242+
required = translate('required.required')
243+
} else if (param.required === false) {
244+
required = translate('required.optional')
245+
} else {
246+
required = param.required
247+
}
248+
249+
const descriptionElements: RichTextList['elements'] = []
250+
251+
if (param.description) {
252+
descriptionElements.push({
253+
type: 'rich_text_section',
254+
elements: [
255+
{
256+
type: 'text',
257+
text: `${translate('description')}: ${param.description}`
258+
}
259+
]
260+
})
261+
}
262+
263+
if (required !== 'N/A') {
264+
descriptionElements.push({
265+
type: 'rich_text_section',
266+
elements: [
267+
{
268+
type: 'text',
269+
text: `${translate('required')}: ${required}`
270+
}
271+
]
272+
})
273+
}
274+
275+
if (param.example !== 'N/A') {
276+
descriptionElements.push({
277+
type: 'rich_text_section',
278+
elements: [
279+
{
280+
type: 'text',
281+
text: `${translate('example')}: ${param.example}`
282+
}
283+
]
284+
})
285+
}
286+
287+
if (param.enum.length > 0) {
288+
const enumElementList: RichTextElement[] = []
289+
290+
for (const e of param.enum) {
291+
const isFirstIteration = enumElementList.length === 0
292+
293+
enumElementList.push({
294+
type: 'text',
295+
text: isFirstIteration ? 'ENUM: ' : ', '
296+
})
297+
enumElementList.push({
298+
type: 'text',
299+
text: e,
300+
style: {
301+
code: true
302+
}
303+
})
304+
}
305+
306+
descriptionElements.push({
307+
type: 'rich_text_section',
308+
elements: enumElementList
309+
})
310+
}
311+
312+
if (param.changeLogs.length > 0) {
313+
const changeLogElementList: RichTextElement[] = []
314+
315+
for (const changeLog of param.changeLogs) {
316+
const { field, oldValue, newValue } = changeLog
317+
318+
changeLogElementList.push({
319+
type: 'text',
320+
text: `${field} ${translate(
321+
'status.modified'
322+
)}: ${oldValue} -> ${newValue}`
323+
})
324+
}
325+
326+
descriptionElements.push({
327+
type: 'rich_text_section',
328+
elements: changeLogElementList
329+
})
330+
}
331+
240332
const description: RichTextList = {
241333
type: 'rich_text_list',
242334
style: 'bullet',
243335
indent: 0,
244336
border: 1,
245-
elements: [
246-
{
247-
type: 'rich_text_section',
248-
elements: [
249-
{
250-
type: 'text',
251-
text:
252-
param.description ||
253-
translate('exception.missing-description')
254-
}
255-
]
256-
},
257-
258-
{
259-
type: 'rich_text_section',
260-
elements: [
261-
{
262-
type: 'text',
263-
text: param.required ? 'Required' : 'Optional'
264-
}
265-
]
266-
}
267-
]
337+
elements: descriptionElements
268338
}
269339

270340
const newline: RichTextSection = {

src/types/locale.ts

+4
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ export interface Locale {
2121
repository: string
2222

2323
'exception.missing-description': string
24+
25+
description: string
26+
required: string
27+
example: string
2428
}

0 commit comments

Comments
 (0)