mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 16:19:10 +03:00
* add deprecate notice * support old icons still * Remove unused icons. * Fix the icons in stories. * Remove console.log --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
85 lines
1.9 KiB
JavaScript
85 lines
1.9 KiB
JavaScript
const fs = require('fs')
|
|
const util = require('util')
|
|
var icons = require('./icons.json') //with path
|
|
|
|
let iconList = {}
|
|
let importList = []
|
|
|
|
//
|
|
// create icon .tsx files
|
|
//
|
|
|
|
Object.values(icons).map((icon) => {
|
|
iconList[`Icon${icon.name}`] = `src/components/Icon/icons/Icon${icon.name}/index.tsx`
|
|
importList.push(`export * as Icon${icon.name} from './Icon${icon.name}'`)
|
|
|
|
var dir = `src/components/Icon/icons/Icon${icon.name}`
|
|
|
|
fs.mkdir(dir, { recursive: true }, (err) => {
|
|
if (err) throw err
|
|
})
|
|
|
|
fs.writeFile(
|
|
`${dir}/index.tsx`,
|
|
`export { default as Icon${icon.name} } from './Icon${icon.name}'`,
|
|
function (err) {
|
|
if (err) return console.log(err)
|
|
}
|
|
)
|
|
|
|
fs.writeFile(
|
|
`${dir}/Icon${icon.name}.tsx`,
|
|
`// DO NOT EDIT
|
|
// this file is generated by /internals/populate-icons script
|
|
import * as React from 'react'
|
|
// @ts-ignore
|
|
import { ${icon.name} } from 'react-feather'
|
|
import IconBase from './../../IconBase'
|
|
|
|
function Icon${icon.name}(props: any) {
|
|
return <IconBase icon={${icon.name}} {...props} />
|
|
}
|
|
|
|
/**
|
|
* @deprecated This icon component should not be used.
|
|
* Please use lucide react icons instead.
|
|
*
|
|
* Replace with:
|
|
* import { ${icon.name.charAt(0).toLowerCase() + icon.name.slice(1)} } from 'lucide-react'
|
|
*/
|
|
export default Icon${icon.name}
|
|
`,
|
|
function (err) {
|
|
if (err) return console.log(err)
|
|
// console.log(`${icon.name} > ${icon.path}`)
|
|
}
|
|
)
|
|
})
|
|
|
|
//
|
|
// create export file for icons
|
|
//
|
|
|
|
fs.writeFile(
|
|
`src/components/Icon/icons/index.tsx`,
|
|
`// export icons
|
|
${importList
|
|
.map((icon) => {
|
|
return `${icon}\n`
|
|
})
|
|
.join('')}`,
|
|
function (err) {
|
|
if (err) return console.log(err)
|
|
// console.log(`wrote file for rollup`)
|
|
}
|
|
)
|
|
|
|
//
|
|
// create input destinations for rollup
|
|
//
|
|
|
|
fs.writeFile(`internals/icons.js`, `export default ${util.inspect(iconList)}`, function (err) {
|
|
if (err) return console.log(err)
|
|
// console.log(`wrote file for rollup`)
|
|
})
|