Skip to content

Commit

Permalink
refactor: option name
Browse files Browse the repository at this point in the history
  • Loading branch information
kawamataryo committed Dec 17, 2022
1 parent 7aa24bb commit 24438ae
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
|BACKGROUND_END|`#0E5593`|カード背景のグラデーションの end color|
|LANG|`ja`|スコアの表記方法(`ja` or `en`|
|CARD_WIDTH|`400`|出力する画像のwidth|
|UPDATE_TIME|`true`|スコアの更新日時の表示有無|

[lapras-card-generator](https://lapras-card-generator.vercel.app) を使うことで生成画像のPreviewや、環境変数の出力も可能です。

Expand All @@ -79,4 +80,3 @@ jobs:
Exportボタンの `GitHub Actions params` で、環境変数をコピーできます。

![CleanShot 2022-12-17 at 21 41 44](https://user-images.githubusercontent.com/11070996/208242401-decb0cbb-c2dd-4ce4-832b-8ae83d6e74aa.png)

6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ inputs:
required: false
description: 'card width'
default: '400'
HIDE_UPDATE_TIME:
UPDATE_TIME:
required: false
description: 'hide update time'
default: 'false'
description: 'display of score update date and time'
default: 'true'
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/lib/rewriteReadmeToIncludeCardText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const createCardText = ({
theme,
lang,
cardWidth,
hideUpdateTime,
showUpdateTime,
}: {
shareId: string
score: Score
theme: Theme
lang: Language
cardWidth: string
hideUpdateTime: boolean
showUpdateTime: boolean
}): string => {
const imageUrl = `https://lapras-card-generator.vercel.app/api/svg?e=${
score.eScore
Expand All @@ -24,7 +24,7 @@ const createCardText = ({
theme.icon.first
)}&i2=${encodeURIComponent(theme.icon.second)}&l=${lang}`

const updateTime = hideUpdateTime ? '' : ` \nLast Updated on ${new Date().toLocaleString()}`
const updateTime = showUpdateTime ? ` \nLast Updated on ${new Date().toLocaleString()}` : ''

return `<a href="https://lapras.com/public/${shareId}" target="_blank" rel="noopener noreferrer"><img src="${imageUrl}" width="${cardWidth}" ></a>${updateTime}}`
}
Expand All @@ -37,17 +37,17 @@ export const rewriteReadmeToIncludeCardText = (
theme,
lang,
cardWidth,
hideUpdateTime,
showUpdateTime,
}: {
shareId: string
score: Score
theme: Theme
lang: Language
cardWidth: string
hideUpdateTime: boolean
showUpdateTime: boolean
}
): string => {
const re = new RegExp(`(${MARK.START})[\\s\\S]*(${MARK.END})`)
const cardText = createCardText({shareId, score, theme, lang, cardWidth, hideUpdateTime})
const cardText = createCardText({shareId, score, theme, lang, cardWidth, showUpdateTime})
return readme.replace(re, `$1\n${cardText}\n$2`)
}
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function run(): Promise<void> {
const lang = core.getInput('LANG') as Language
const cardWidth = core.getInput('CARD_WIDTH')
const token = core.getInput('GH_TOKEN')
const hideUpdateTime = core.getInput('HIDE_UPDATE_TIME') === 'true'
const showUpdateTime = core.getInput('UPDATE_TIME') === 'true'

const readmeContent = await fetchPrevReadmeContent(token)
const score = await fetchScore(shareId)
Expand All @@ -32,7 +32,7 @@ async function run(): Promise<void> {
theme,
lang,
cardWidth,
hideUpdateTime
showUpdateTime
})

await updateReadme({ghToken: token, readme, sha: readmeContent.sha})
Expand Down

0 comments on commit 24438ae

Please sign in to comment.