mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* refactor: migrate eslint to v9 * chore: lint * chore: update eslint command * chore: fix lint warnings * chore: separate lint and lint:fix * chore: exclude contentlayer generated code * fix(scripts): add missing await
63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
/**
|
|
* This module was inspired by chakra-ui ❤️
|
|
*/
|
|
|
|
|
|
import {promises as fs} from 'fs'
|
|
import path from 'path'
|
|
|
|
import ImageSharp from './image-sharp'
|
|
|
|
import { getSponsors } from '@/utils/get-sponsors'
|
|
|
|
|
|
|
|
const publicDir = path.join(process.cwd(), 'public')
|
|
const sponsorsDir = path.join(publicDir, 'sponsors')
|
|
|
|
|
|
async function buildSponsors() {
|
|
const sponsors = await getSponsors()
|
|
|
|
// cache sponsor image
|
|
const sponsorCache = new ImageSharp({
|
|
outputDirectory: sponsorsDir,
|
|
})
|
|
|
|
// update the image property from open-collective to use the cached image
|
|
const allSponsors = await Promise.all(
|
|
sponsors.map(async (s) => {
|
|
const filename = await sponsorCache.urlToFile(
|
|
s.image,
|
|
s.MemberId.toString(),
|
|
)
|
|
|
|
return {
|
|
...s,
|
|
image: `/sponsors/${filename}`,
|
|
}
|
|
}),
|
|
)
|
|
|
|
|
|
await fs.writeFile('.sponsorsrc', JSON.stringify(allSponsors, null, 2))
|
|
}
|
|
|
|
|
|
async function build() {
|
|
// make sure the sponsors directory exists
|
|
try {
|
|
await fs.access(sponsorsDir);
|
|
} catch {
|
|
await fs.mkdir(sponsorsDir, { recursive: true });
|
|
}
|
|
await Promise.all([buildSponsors()])
|
|
}
|
|
|
|
try {
|
|
build()
|
|
} catch (err) {
|
|
// eslint-disable-next-line no-console
|
|
console.log(err)
|
|
}
|