(sponsors: Sponsor[])
| 175 | } |
| 176 | |
| 177 | function buildWebsiteSponsorsFileContent(sponsors: Sponsor[]): string { |
| 178 | const normalizedSponsors = sponsors.map((sponsor) => { |
| 179 | const createdAt = typeof sponsor.createdAt === 'string' && sponsor.createdAt.length > 0 |
| 180 | ? sponsor.createdAt |
| 181 | : undefined |
| 182 | |
| 183 | const sidebarSize = sponsor.sidebarSize === 'normal' || sponsor.sidebarSize === 'small' || sponsor.sidebarSize === 'none' |
| 184 | ? sponsor.sidebarSize |
| 185 | : 'none' |
| 186 | |
| 187 | const sidebarLogo = typeof sponsor.sidebarLogo === 'string' && sponsor.sidebarLogo.length > 0 |
| 188 | ? sponsor.sidebarLogo |
| 189 | : sponsor.avatar |
| 190 | |
| 191 | return { |
| 192 | name: sponsor.name, |
| 193 | login: sponsor.login, |
| 194 | avatar: sponsor.avatar, |
| 195 | amount: sponsor.amount, |
| 196 | link: sponsor.link, |
| 197 | org: sponsor.org, |
| 198 | ...(createdAt ? { createdAt } : {}), |
| 199 | tierTitle: sponsor.tierTitle, |
| 200 | tierLevel: sponsor.tierLevel, |
| 201 | sidebarSize, |
| 202 | sidebarLogo, |
| 203 | } |
| 204 | }) |
| 205 | // eslint-disable-next-line ban/ban |
| 206 | const sponsorsJson = JSON.stringify(normalizedSponsors, null, 2) |
| 207 | |
| 208 | return `// This file is auto-generated by scripts/sync-sponsor.ts. Do not edit manually. |
| 209 | |
| 210 | export type SidebarPlacementSize = 'normal' | 'small' | 'none' |
| 211 | |
| 212 | export interface JSONSponsor { |
| 213 | name: string | null |
| 214 | login: string |
| 215 | avatar: string |
| 216 | amount: number |
| 217 | link: string |
| 218 | org: boolean |
| 219 | createdAt?: string |
| 220 | tierTitle: string |
| 221 | tierLevel: number |
| 222 | sidebarSize: SidebarPlacementSize |
| 223 | sidebarLogo: string |
| 224 | } |
| 225 | |
| 226 | export const sponsors: JSONSponsor[] = ${sponsorsJson} |
| 227 | ` |
| 228 | } |
| 229 | |
| 230 | async function writeWebsiteSponsorsFile(sponsors: Sponsor[]): Promise<void> { |
| 231 | await mkdir(path.dirname(WEBSITE_SPONSORS_FILE), { recursive: true }) |
no outgoing calls
no test coverage detected